0

How do I invert a character string in c ++?

2nd Apr 2020, 3:15 AM
jhon sebastian zuñiga lopez
jhon sebastian zuñiga lopez - avatar
2 Réponses
+ 3
#In C++ you can use `reverse` function from <algorithm> ``` std::string s="reverseit"; std::reverse(s.begin(),s.end()); cout<<s; ``` https://www.sololearn.com/discuss/2175825/?ref=app You can also use loop: ``` std::string s="reverseit"; for(size_t i= s.length()-1;i>=0;i--) std::cout<<s.at(i); ``` You can find other ways on internet. Remove irrelevant tags. use "c++" , "reverse","string"
2nd Apr 2020, 3:36 AM
🇮🇳Omkar🕉
🇮🇳Omkar🕉 - avatar
+ 1
thanks
2nd Apr 2020, 5:34 AM
jhon sebastian zuñiga lopez
jhon sebastian zuñiga lopez - avatar