fork download
  1. #include<cstring>
  2. #include<limits>
  3. #include<iostream>
  4. using namespace std;
  5. int main()
  6. {
  7. char targetString[100] = "fox";
  8. char targetString2[100] = "the";
  9. char strings[100];
  10. cin>>strings;
  11. double minDistance = std::numeric_limits<double>::infinity();
  12. for (int x = 0; x < strlen(strings); x++)
  13. {
  14. if (strings[x].equals(targetString))
  15. {
  16. for (int y = x; y < strings->length; y++)
  17. {
  18. if (strings[y].equals(targetString2))
  19. {
  20. if (minDistance > (y - x))
  21. {
  22. minDistance = y - x;
  23. }
  24. }
  25. }
  26. for (int y = x; y >= 0; y--)
  27. {
  28. if (strings[y].equals(targetString2))
  29. {
  30. if (minDistance > (x - y))
  31. {
  32. minDistance = x - y;
  33. }
  34. }
  35. }
  36. }
  37. }
  38. cout<<minDistance;
  39. return 0;
  40. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
the quick the brown fox the
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:14:17: error: request for member ‘equals’ in ‘strings[x]’, which is of non-class type ‘char’
  if (strings[x].equals(targetString))
                 ^~~~~~
prog.cpp:16:32: error: request for member ‘length’ in ‘*(char*)(& strings)’, which is of non-class type ‘char’
   for (int y = x; y < strings->length; y++)
                                ^~~~~~
prog.cpp:18:19: error: request for member ‘equals’ in ‘strings[y]’, which is of non-class type ‘char’
    if (strings[y].equals(targetString2))
                   ^~~~~~
prog.cpp:28:19: error: request for member ‘equals’ in ‘strings[y]’, which is of non-class type ‘char’
    if (strings[y].equals(targetString2))
                   ^~~~~~
stdout
Standard output is empty