0

Reverse String

Does anyone know a simple code to display the input string in reverse? Example Input: hello Output: olleh https://code.sololearn.com/cU4SaI6hZ90d/?ref=app

6th Aug 2019, 4:51 PM
Jacques Cozart
Jacques Cozart - avatar
2 Respostas
+ 3
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]; }
6th Aug 2019, 6:05 PM
blACk sh4d0w
blACk sh4d0w - avatar
0
Thank you!
6th Aug 2019, 7:23 PM
Jacques Cozart
Jacques Cozart - avatar