using this for cin
1 2 3 4 5 6
|
ofstream newsuspect("newsuspect.txt", ios::app);
system("cls");
cin.ignore();
cout << "Enter the new suspect's name" << endl;
getline(cin,name);
newsuspect << name;
| |
& this code to read from file
1 2 3 4
|
ifstream suspect("newsuspect.txt");
while (suspect >> name ){
cout << setw(10)<< name << setw(10) << age <<setw(10)<< cno <<' '<<endl ;
}
| |
IT doesnt read whole string (including spaces)
Last edited on
You can just use while(getline(suspect,name))
as well.
some random number shows up :/