Write a program that will create userids for email addresses of a company. Names of employees will be contained in a file. Your task is to read the file character by character. Employee names are separated by semicolons. The process of creating a userid is as follows:
The first 8 characters, excluding spaces and non-alphabetical characters becomes the userid. Your program will therefore ignore all spaces and non-alphabetical characters from the input file. If the employee name excluding spaces and non-alphabetical characters consists of less than 8 characters, the userid will also contain less than 8 characters. (e.g. JG Smit will give a userid of jgsmit and GM Bezuidenhout will give a userid of gmbezuid.
You will however not work with the full surname. Your program will read character by character, and form the userid as you go along, adding each new character of the id to the output file. Call the output file userid.dat. As soon as you read a semicolon, the previous userid is complete and you can then write the semicolon to the output file to separate the userids. You therefore have to plan the logic properly, so that you don’t have to go back to the output file to delete characters that should not be there.
Create an input file called employee.dat with the following data:
SS van der Merwe;PJ Ferreira;HW du Plessis;DF Kodisang;AA
Papoudopolous;G Mhlanga;TRF Schoeman;LJ Marais Le Roux;CG
Roux;B Nicholaidis;TT Tshabalala;RV Mississipi;
Allow the user to specify the name of the input file.
That is my question, the part where i struggle and have no idea what coding to use as i cant see that this has been covered yet in our syllabus, is where you have to read the name and surname between the semicolon from the input file
i have to create the input file with the extension .dat with the following data inside
SS van der Merwe;PJ Ferreira;HW du Plessis;DF Kodisang;AA
Papoudopolous;G Mhlanga;TRF Schoeman;LJ Marais Le Roux;CG
Roux;B Nicholaidis;TT Tshabalala;RV Mississipi;
also i want to know is there anyway i can link an input string such as
char InputFileName
cout << "Enter the name of the file you want to open";
cin >> InputFileName
The InputFileName regardless of what is entered by the user needs to be linked to a input file i created called employee.dat so that the program understands whenever InputFileName is referred to in the program that it will know to use the employee.dat
You don't need to use sstream. I only used sstream to give you an example since I can't post actual files here. You would need to replace sstream with a fstream object and filename.