I have created a list class, that allows the user to create or edit a text file with a list of information inside the .txt file. When I read into the alphabet.txt (a .txt with a list of all the letters), it prints out the letter "z" twice. The editing that the user does is shown between the two "z's." I'm attaching a picture that explains my dillemna.
Another problem is when I print the contents of the file, it does not print the contents of the entire file.
Thank You in advance.
below is a chunk of my List.cpp file.
void List::EditText()
{
char nameoffile[60];
char a[50][100];
string line;
ifstream thefile;
ofstream myFile;
cout <<"The following files are available for editing: \n";
cout <<"alphabet.txt\n";
cout <<"buildings.txt\n";
cout <<"engineering.txt\n";
cout<< "Name the .txt file that you wish to open\n";
cin.getline(nameoffile, 60);
cout << "Below displays the content of the file you selected" << endl << endl;
thefile.open(nameoffile);
int response, i;
cout << "Enter the number of entries you would like to edit" << endl;
cin >> response;
myFile.open(nameoffile, fstream::app);
cout << endl;
for(i=0; i < response; i++)
{
cout << "Enter your item" << endl;
cin >> a[i];
myFile << a[i] << endl;
}
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.