Im trying to read lines in from a txt file to write into another txt file but at the moment its only reading the first line. I need it to read 1 line at a time and store it to add to another txt file before reading the next line. Id like it to read the name then the company name and store both in different varibles.
The text file we be:
Alan Jones 1ST CDR
Lucy adams 1ST CDR
double a; // When I is = to A program stops Amount of names is stored as A
double i;
i=0;
char names [50];
char company [50];
char count [2];
string q;
cout <<"Enter amount of names\n";
cin.getline (count,2);
a = atoi (count); //Converts a char to int needed when cin.getline is used
do
{
i=i+1;
fstream name;
name.open ("names.txt", ios::in); //Opens The text document
getline (name,q);
fstream xml;
xml.open("xml.txt",ios::out);
xml <<q; //Enters The name into the Text Document
name.close();
xml.close();
}while (i != a);