#include < iostream >
#include < string >
using namespace std;
void reverseStr(string& x)
{
string temp = "";
int len = x.length();
for(int i = len - 1; i >= 0; --i)
{
temp += x[i];
}
x = temp;
}
int main()
{
string x = "Hello World!";
cout << "x = " << x << endl;
reverseStr(x);
cout << "x = " << x << endl;
return 0;
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment