Write a C program that reads in a list of first and last nam
Write a C++ program that reads in a list of first and last names from an input data file named people.txt. The program should create a user name for each person consisting of the last name and the first initial of the first name. The program should print the first name, the last name, and the created user name for each person to the output data file usernames.txt. The program must use an end-of-file (EOF) loop.
Solution
people.txt (Save this file under D Drive .Then the path of the file pointing to it is D:\\\\people.txt)
Willaims Kane
 Johnson Mitchel
 Sachin Tendulkar
 Vinod kamblie
 Sanjay Manjrekar
 Ravi sastri
 Ricky Pointing
 Clarke Michael
_____________________
code:
#include <iostream>
 #include <string>
 #include <fstream>
 #include<iomanip>
using namespace std;
int main()
 {
    //Declaring variables
    string fname,lname;
string uname;
   
    int index=0;
   
 //defines an input stream for the data file  
 ifstream dataIn;
   
 //Defines an output stream for the data file
 ofstream dataOut;
   
 //Opening the input file
 dataIn.open(\"D:\\\\people.txt\");
   
 //creating and Opening the output file
 dataOut.open(\"D:\\\\usernames.txt\");
//This loop continues to execute until the end of the file
 while (!dataIn.eof( ))
 {
    
     //reading the firstname and lastname from people.txt file
     dataIn>>fname>>lname;
    
     //Concatinating the firstname first letter with the lastname
     uname=lname+fname.at(index);
    
     //Storing the user name in the txt file
     dataOut<<fname<<\" \"<<lname<<\" \"<<uname<<endl;
 }
 
 //Closing the input stream
    dataIn.close()   ;
      
    //Closing the output stream
    dataOut.close();
      
    return 0;
 }
_____________________
usernames.txt (We will get this file under D Drive.As we specified the path as D:\\\\usernames.txt )
Willaims Kane KaneW
 Johnson Mitchel MitchelJ
 Sachin Tendulkar TendulkarS
 Vinod kamblie kamblieV
 Sanjay Manjrekar ManjrekarS
 Ravi sastri sastriR
 Ricky Pointing PointingR
 Clarke Michael MichaelC
 Clarke Michael MichaelC
__________Thank You


