1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
#include <iostream>
#include <string>
using namespace std;
int main()
{
string information;
int name, ssn, userID, password;
cout << "Enter a student's name, social security number(include dashes), user id, and password in one line:" << endl;
getline(cin, information);
cout << endl;
name = information.find(' ', 0);
cout <<"name is " <<name <<endl;
ssn = information.find(' ', name + 1);
cout << "ssn is " <<ssn<<endl;
information.replace(name + 1, 3, "xxx");
information.replace(name + 5, 2, "xx");
information.replace(name + 8, 4, "xxxx");
userID = information.find(' ', ssn + 1);
cout << "userID is " <<userID<<endl;
for(unsigned int i=userID+1; i <information.length(); i++){
information.replace(i,1,"x");
}
cout << information << endl;
cin.clear();
getchar();
return 0;
}
|