Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hey everyone, I have this program which takes input as a fileand replaces three

ID: 3617091 • Letter: H

Question

Hey everyone,   I have this program which takes input as a fileand replaces three characters with first name and last name userenters. I am sort of stuck with my code in this one, i am postingit below if anyone can help me out it would be appreciated. Here ismy source code. If you want the file, I am posting the contents ofit and you can just create your own file and replace this string"#N#" with first and last name entered by user. #include <iostream> #include <fstream> #include <cstring> #include <string> using namespace std;   char fileName[20];   char outFile[20];   char firstName[30];   char lastName[30];   ifstream inStream;   ofstream outStream; void removeChar(ifstream& inStream, ofstream&outStream); int main() {   cout<<"Enter the name of file containing theletter body."<<endl<<"-- 20 charactersmax"<<endl;   cin>>fileName;   inStream.open(fileName,ios::in);   if(!fileName){   cout<<"Input file opening failed. ";   return 0;   }   cout<<"Enter the name of file for thefinished letter."<<endl<<"-- 20 charactersmax"<<endl;   cin>>outFile;   outStream.open(outFile);   if(!outFile){   cout<<"Outout file opening failed. ";   }   cout<<"Please enter a first name and hitenter: ";   cin>>firstName;   cout<<"Last name? "<<endl;   cin>>lastName;      removeChar(inStream,outStream);   inStream.close();   outStream.close();   cout<<"done with replace";   system("pause");   return 0; } void removeChar(ifstream& inStream, ofstream&outStream){   char next;   inStream.get(next);   while(!inStream.eof()){    if (next=='N'){    inStream.get(next);    if(next=='#'){    inStream.get(next);    if(next=='#'){    outStream<<firstName<<""<<lastName;    } }    else    outStream<<next;    inStream.get(next); }    } }
  I have this program which takes input as a fileand replaces three characters with first name and last name userenters. I am sort of stuck with my code in this one, i am postingit below if anyone can help me out it would be appreciated. Here ismy source code. If you want the file, I am posting the contents ofit and you can just create your own file and replace this string"#N#" with first and last name entered by user. #include <iostream> #include <fstream> #include <cstring> #include <string> using namespace std;   char fileName[20];   char outFile[20];   char firstName[30];   char lastName[30];   ifstream inStream;   ofstream outStream; void removeChar(ifstream& inStream, ofstream&outStream); int main() {   cout<<"Enter the name of file containing theletter body."<<endl<<"-- 20 charactersmax"<<endl;   cin>>fileName;   inStream.open(fileName,ios::in);   if(!fileName){   cout<<"Input file opening failed. ";   return 0;   }   cout<<"Enter the name of file for thefinished letter."<<endl<<"-- 20 charactersmax"<<endl;   cin>>outFile;   outStream.open(outFile);   if(!outFile){   cout<<"Outout file opening failed. ";   }   cout<<"Please enter a first name and hitenter: ";   cin>>firstName;   cout<<"Last name? "<<endl;   cin>>lastName;      removeChar(inStream,outStream);   inStream.close();   outStream.close();   cout<<"done with replace";   system("pause");   return 0; } void removeChar(ifstream& inStream, ofstream&outStream){   char next;   inStream.get(next);   while(!inStream.eof()){    if (next=='N'){    inStream.get(next);    if(next=='#'){    inStream.get(next);    if(next=='#'){    outStream<<firstName<<""<<lastName;    } }    else    outStream<<next;    inStream.get(next); }    } } #include <iostream> #include <fstream> #include <cstring> #include <string> using namespace std;   char fileName[20];   char outFile[20];   char firstName[30];   char lastName[30];   ifstream inStream;   ofstream outStream; void removeChar(ifstream& inStream, ofstream&outStream); int main() {   cout<<"Enter the name of file containing theletter body."<<endl<<"-- 20 charactersmax"<<endl;   cin>>fileName;   inStream.open(fileName,ios::in);   if(!fileName){   cout<<"Input file opening failed. ";   return 0;   }   cout<<"Enter the name of file for thefinished letter."<<endl<<"-- 20 charactersmax"<<endl;   cin>>outFile;   outStream.open(outFile);   if(!outFile){   cout<<"Outout file opening failed. ";   }   cout<<"Please enter a first name and hitenter: ";   cin>>firstName;   cout<<"Last name? "<<endl;   cin>>lastName;      removeChar(inStream,outStream);   inStream.close();   outStream.close();   cout<<"done with replace";   system("pause");   return 0; } void removeChar(ifstream& inStream, ofstream&outStream){   char next;   inStream.get(next);   while(!inStream.eof()){    if (next=='N'){    inStream.get(next);    if(next=='#'){    inStream.get(next);    if(next=='#'){    outStream<<firstName<<""<<lastName;    } }    else    outStream<<next;    inStream.get(next); }    } }

Explanation / Answer

//Hope this will helpyou.. #include #include #include #include #include using namespace std;char fileName[20];char outFile[20];char firstName[30];char lastName[30];ifstream inStream;ofstream outStream;void removeChar(ifstream& inStream, ofstream& outStream);int main(){cout