使用范围for语句将字符串内的所有字符用X代替
#include <iostream>
#include <string>
using namespace std;
int main()
{
string s("0123456789");
cout << s << endl;
for (auto &c : s)
c = 'X';
cout << "the data is:\n" << s << endl;
system("pause");
return 0;
}
使用范围for语句将字符串内的所有字符用X代替
#include <iostream>
#include <string>
using namespace std;
int main()
{
string s("0123456789");
cout << s << endl;
for (auto &c : s)
c = 'X';
cout << "the data is:\n" << s << endl;
system("pause");
return 0;
}