Can someone help me with this program

Hi everybody it is my first time that I used this forum.
I hope that somebody can help me because I really would like to know what I did wrong.


Write a program that reads in a line consisting of a student’s name, Social Security number, user ID, and password. The program outputs the string in which all the digits of the Social Security number, and all the characters in the password are replaced by x. (The Social Security number is in the form 000-00-0000, and the user ID and the password do not contain any spaces.) Your program should not use the operator [] to access a string element.



#include <iostream>
#include <string>

using namespace std;

int main()
{
string input; //Define input

int ssn; //Define SSN

int password; //Define password
int un;

cout << "Enter a student's name, social security number, user id, and password in one line:" << endl; //Show command line
getline(cin, input); //Input

ssn = input.find(' ', 0); //Sets SSN as input after first occurance of space

input.replace(ssn + 1, 11, "xxxxxxxxx"); //Starting at the ' ' then next 11 characters will be replaced by x's

ssn = input.find(' ', ssn + 12); //Looks for ' ' after SSN and 12 digits
password = input.length(); //Returns the new value of SSN + 6

password = password - ssn; //Password length now is length minus SSN legth

input.erase(ssn, password); //Deletes all characters of SSN and password

input.insert(ssn, password, 'x'); //Inserts x's for all characters in SSN and password

un = input.length()-password;
char c=' ';
input.insert(un,1,c);

cout <<""<< endl;

cout << input << endl; //Output is "input" plus replacement x's

return 0;
}
Please use [ Code ] [ /Code ] tags to make it easier to read.

Tell us why it isn't currently working, we don't want to have to run all of your programs.
The output is not corret and I get 4 errors "Implicit conversion loses integer precision: 'size_type' (aka 'unsigned long') to 'int' "

at

ssn = input.find(' ', 0);
ssn = input.find(' ', ssn + 12);
password = input.length();
un = input.length()-password;


input
John Smith 222-22-2222 S12345 password
the correct output suppose to be
John Smith xxx-xx-xxxx S12345 xxxxxxxx
Topic archived. No new replies allowed.