I'm teaching myself c++, and after searching around on the forums, I couldn't find an answer that helped me with this specific problem.
The idea is to collect the first name, last name, and SSN of a customer, and create a file using the first three letters of the first name adn last name, and the last four of the SSN to create a file name.
Sample input
Sam
Bronikowsky
5555
The file name would read sambro5555
heres the section of code i've written.
void new_customer()
{
string f_name, l_name, name_file;
string ssn;
char yesno;
cout<<"You have selected 'New Customer'"<<endl;
getch();
do
{
system("cls");
cout<<"First Name: ";
cin>>f_name;
cout<<"Last Name: ";
cin>>l_name;
cout<<"Last Four Didgets of Social Security: ";
cin>>ssn;
system("cls");
cout<<l_name<<", "<<f_name<<endl<<ssn<<endl;
cout<<"Is this correct? Y / N"<<endl;
yesno = getch();
}while (yesno != 121);
system("cls");
name_file = f_name.substr(0, 3) + l_name.substr(0, 3) + ssn;
cout<<name_file;
ofstream out_to_file (name_file);
out_to_file<<f_name<<" "<<l_name;
}
so how can I get the string variables to read out as a custom file name?