Reverse String | Sololearn: Learn to code for FREE!


Reverse String

Does anyone know a simple code to display the input string in reverse? Example Input: hello Output: olleh

8/6/2019 4:51:03 PM

Jacques Cozart

2 Answers

New Answer


You also need to include cstring library for strlen() function. .c_str() is used to convert string to C-Style char array. for(int i = strlen(input.c_str()) - 1; i >= 0; i--) { cout << input[i]; }


Thank you!