+ 1

how to get reverse string without using strrev()

1st Oct 2017, 9:24 AM
Ashwini Khanderao Kulkarni
Ashwini Khanderao Kulkarni - avatar
2 Respuestas
+ 17
#include <iostream> #include <string> using namespace std; int main() { string str1 = "Hello"; string str2 = "*****"; for (size_t i = str1.length() - 1, j = 0; (i >= 0 && i <= str1.length() - 1) ; --i, ++j) str2[j] = str1[i]; cout << str2; } [https://code.sololearn.com/c0qBu1GwZRl8]
1st Oct 2017, 9:44 AM
Babak
Babak - avatar
+ 1
thank you
1st Oct 2017, 9:43 AM
Ashwini Khanderao Kulkarni
Ashwini Khanderao Kulkarni - avatar