How do you replace every occurrence of a space character with an underscore? (this is for C++ but we are using c-strings)

  c++
char *Space(char *s) //param s is the C-string to process (non-const) and i have to return a 
                     //pointer to modified string
for (int i{0}; s[i] != '{$content}'; ++i)
   {
      if (s[i] == ' ')
      {
        s[i] = '_';
      }
   } 

That’s what I’ve written so far for the body because the function itself was given, but I’m stuck on how to continue it.

Source: Windows Questions C++

LEAVE A COMMENT