Reverse String | Sololearn: Learn to code for FREE!

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

8/6/2019 4:51:03 PM

Jacques Cozart

2 Answers

New Answer

+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!