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
2 ответов
+ 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];
}
0
Thank you!