fork(2) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int compare(const char* string1, const char* string2)
  5. {
  6. if(string1 == NULL || string2 == NULL)
  7. return 0;
  8.  
  9. // This needs to go here
  10. if(*string1 == '\0' && *string2 == '\0')
  11. return 1;
  12.  
  13. std::cout << *string1 << " | " << *string2 << std::endl;
  14. if((!isalpha(*string1) && *string1 != ' ') && (!isalpha(*string2) && *string2 != ' '))
  15. {
  16. return compare(++string1,++string2);
  17. }
  18. else if(!isalpha(*string1) && *string1 != ' ')
  19. {
  20. return compare(++string1,string2);
  21. }
  22. else if(!isalpha(*string2) && *string2 != ' ')
  23. {
  24. return compare(string1, ++string2);
  25. }
  26.  
  27. if(tolower(*string1) != tolower(*string2))
  28. return 0;
  29. if(*string1 == *string2)
  30. return compare(++string1, ++string2);
  31. }
  32.  
  33. int main() {
  34. cout << compare("a !!!b", "a b");
  35. return 0;
  36. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
a | a
  |  
! | b
! | b
! | b
b | b
1