If what I think I'm doing is correct, this should reverse a string, yes?Code://function declaration string stringReverse(string arg) { string word = arg; for(int i = word.length(); i >= 0; i--) { char temp; word[0] = temp; word[0] = word[i]; word[i] = temp; } return word; }
When I pass soemthing to the function, and then output the result - only blank spaces appear on the screen. Am I going out of bounds? What am I doing wrong here?