Hey guys am new to c++...so am trying to write a program in c++ that will read from two files...i need it to read from the first file and store data in variables firstName,lastName and Registration code,the using the registration code it checks or search in the second fiile if the registration code exists in the second file..
Any help will be greatly appreciated
Try to write some code yourself, and once you get stuck, post what you've tried, and we can help you from there. Also, show how the file are formatted.
Let's assume that the secondFile has the same format as firstFile.
1 2 3 4 5 6 7 8 9 10 11
string first_name, last_name;
int reg_code;
second.open("StoreDatabase.txt");
if (second)
{
while (second >> first_name >> last_name >> reg_code)
{
// now compare the input data with the data just read
// if the are equal save them to a new file named confirmed customters
}
}
Thanks Thomas!
So if i were to write that in my code like below....
"From my code"
firstfile >> A >> B >> C;
cout << "First Name: " << A << endl;
cout << "Surname: " << B << endl;
cout << "Registration Code: " << C << endl;
then i write in my code like so
firstfile >> A >> B >> C;
cout << "First Name: " << A << endl;
cout << "Surname: " << B << endl;
cout << "Registration Code: " << C << endl
string first_name, last_name;
int reg_code;
second.open("StoreDatabase.txt");
if (second)
{
while (second >> first_name >> last_name >> reg_code)
{
// now compare the input data with the data just read
// if the are equal save them to a new file named confirmed customters
}
}