As part of the functionality for a college assignment, I am trying to read two variables from a file. These being the following:
- Name - this will store the persons name
- House - this will store a house number
This is currently working, but i would like the user to load another name & house number that is stored within the file, upon pressing the ‘n’ key on their computer’s keyboard.
How can this be done?
See coding so far below.
Many Thanks
Code:
#include <iostream.h>
#include <iomanip.h>
#include <fstream.h>
#include <conio.h>
#include <dos.h>
int main (void)
{
char name[50];
int house[2];
char choice;
do
{
choice = 1;
cin >> choice;
ifstream data (".\\records.txt");
data >> name;
data >> house;
cout << name;
cout << house;
data >> name;
data >> house;
data.close();
} while (choice == 'n');
delay(5000);
return 0;
}