+ 1
how to get reverse string without using strrev()
2 Antworten
+ 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]
+ 1
thank you