after the 2nd time the input function member does not work Y?
the problem is that I want to create a program that gets my house visitora and if they are in my file.txt welcome msg will be displayed, otherwise sorry u r not invited should be displayed
#include <fstream>
#include <iostream>
#include <string.h>
using namespace std;
int main() {
fstream file;
file.open("guests.txt");
if (file.is_open())
cout << "OK";
else
cout << "Error";
char user = 'n';
while (user == 'n') {
int counter = 1;
file.seekg(0);
char visitor[15], guest[15];
clog << " What is your name? ";
cin.getline(visitor, 15);
for (counter; counter <= 100; counter++) {
file >> guest;
if (strcmp(guest, visitor) == 0) {
cout << " Welcome! ";
goto label1;
}
} // end of for loop
cerr << " Sorry dear " << visitor << " you are not invited. ";
label1:
cout << '\n' << " Do you want to exit ? ( y / n ) ";
cin >> user;
}
return 0;
}