I have an assignment where I need to input a certain value, and the computer will then run through an 'txt' file to see if the value is in there, otherwise it will ask you if you want to create a new value or make a new input.
ifstream infil("kundregister.txt");//declares outstream 'utfil' to 'kundregister.txt'
cout<<"...och customernumber: ";
cin>>soktkund;//input of custombernumber typed by the user
while (infil.getline(namn,29))//while loopen checks that the customernumber exists in 'kundregister.txt'
{
//Reads name and address with getline
infil.getline(adress,39);
infil >> kundnr;
infil.get();
if (soktkund==kundnr)// condition that the input value is the same as the customernumber from 'kundregister.txt'
{
hittkund=1;// the custombernumber exists in 'kundregister.txt' the program continues
break;
}// condition closes
}// the loop closes
if(!hittkund)// if the input customernumber doesn't exist in 'kundregister.txt' the following text will show on the screen:
cout<<"kundnummer saknas";
So after this I'm supposed to give the user 2 options, either 'Enter an other customernumber' or 'Return to the menu'
I have tried for ages, but can't find a solution :(
Any help is most appreciated.
Regards,
Kim