Question: Using C++, given a file consisting of student's names in the follwing form: lASTNAME, fIRSTname middleName, write a program that: (1) converst each name to
Using C++, given a file consisting of student's names in the follwing form: lASTNAME, fIRSTname middleName, write a program that: (1) converst each name to the following form while Removing the comma; firstName middleName lastName, (2) Program must read each student's name in a variable and must consist of a function that takes as input A string consisting of the alterd name (first middle last). (3) Use the string function FIND to find the index of the , (comma). the function length to find the length of the string, and the function SUBSTR to extract the firstName, middleNme, and lastName. See following for anticipated format of code with general expectation (must have return string):
#include
#include
#include
Using namespace std;
Ifstream infile;
Ofstream outfile;
String removeComma(string str)
Int main()
{
Cout< String str; Infile.open (data.txt); Outfile.open(:Display.txt); While (1infile.eof()) Infile >> str; {int pos=str.find(,); String beforeComma = str.substr(o, pos); Int Len =str.length-pos-1; String aftercomma= str.substr(pos +1); Infile.close(); Outfile.close(); Return0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
