string replace modifications?

Is there a better way to replace the social security number and password with x's? Just looking for maybe a more practical way of doing this. thanks.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
#include <string>
using namespace std;

int main ()
{
string name = "Bob Saggot";
string soc = "123-45-6789";
string id = "bsaggot";
string pass = "123456789";
int i = 0;

cout << "" << name << endl;

cout << soc.replace(i, 11, "xxx-xx-xxxx") << endl;

cout << "" << id << endl;

cout << pass.replace(i, 9, "xxxxxxxxx") << endl;

  return 0;
}




Last edited on
Topic archived. No new replies allowed.