void display()
{
bool check = true;
ifstream file;
file.open("file.txt", ios::in);
string name, semester, id, findid, gpa;
if (file.fail())
{
cerr << "File Not Created or File Name is Not Valid";
}
else
{
cout << "\nEnter The Id : ";
cin >> findid;
while (file >> id && cin.ignore(40, '\n'), getline(file, name) && file >> semester >> gpa)
{
if (id == findid)
{
cout << name << endl;
cout << id;
cout << semester << endl;
cout << gpa << endl;
check = false;
}
}
file.clear();
file.seekg(0, ios::beg);
}
if (check == true)
cout << "\nStudent Not Found";
}
data in file
12345
Muhammad Salman Zafar
4th
3.00
12346
Muhammad Salman Zafar
4th
3.00
12347
Muhammad Salman Zafar
4th
3.00
if i enter 12345
i get this output
12345
space
Muhammad
Salman
and cmd is stop not moving