Jan 29, 2019 at 12:25am UTC
ofstream outFile;
string student1, student2, student3;
int id1, id2, id3;
outFile.open("names.txt");
cout<<"Please provide your first, and last name, and student id."<<endl;
getline (cin, student1);
cin>>id1;
getline (cin, student2);
cin>>id2;
getline (cin, student3);
cin>>id3;
outFile<<student1<<endl<<id1<<endl<<student2<<endl<<id2<<endl<<student3<<endl<<id3;
outFile.close();
When ever I run and compile the program it stops after the first to cin inputs and I can't figure out why.
Jan 29, 2019 at 12:35am UTC
cin and getline don't play nice sometimes.
I would just use getline for all the reads, if you can. If you can't, it can be fixed, but its more bloat code.