0
How do I invert a character string in c ++?
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"
+ 1
thanks