Ad
  • Custom User Avatar

    Thanks for your help i found what was wrong and corrected it thanks to your tip😁

  • Custom User Avatar

    The string you think is the same as expected is no the same as expected, it just seems to be the same as expected. Due to an off-by-one bug in your solution, it has a stray \0' in the middle. Change the bottom of your function to:

      std::cout<<strr << std::endl;
      for(char c: strr) {
        std::cout << (int)c << ' ';
      }
      std::cout << std::endl;
      
      return strr;
    }// spinWords
    

    ... and you will see that first space is not a space but \0.

  • Custom User Avatar

    Hi, when i try my code it works fine and it even gives the same output as the test case but when the test case run it the return value doesn't show completly so it keeps saying i failed the test and i even displayed the string to make sure that i got the same statement exactly