Ad
  • 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.