A little question | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

A little question

How to flip over the value in string E.g String a = "Hello" //some code Output olleh

26th Feb 2020, 3:10 PM
Rrrrrr
Rrrrrr - avatar
3 Answers
+ 4
You can use string reverse iterator to generate a reversed version, as follows: std::string str {"Hello World"}; std::string reversed {str.crbegin(), str.crend()}; std::cout << reversed;
26th Feb 2020, 3:17 PM
Ipang
+ 5
Loop over the string from back to front printing each char.
26th Feb 2020, 3:14 PM
Mihai Apostol
Mihai Apostol - avatar
+ 5
Tq
26th Feb 2020, 3:17 PM
Rrrrrr
Rrrrrr - avatar