Buffer Help!

Started by
-1 comments, last by kkuhl86 18 years ago
Hey guys, this is regarding some code that I'm writing for class involving classes and methods and things of that nature. Basically im supposed to be writing a Student class with all the regular members of a student and having some methods that compute GPA , read and write that data blah blah... Well ive been having some serious problems with the buffers for input. After printing the schedules and stuff it will randomly stop taking input and crash. I have tried, gets(), getline(), cin.get(), gets_s() for usage and they all work pretty much the same. Is there a way to flush the cin/cout buffer (i know about istream/ostream::flush but it seems to me that I need to fix non-file buffers). Any feedback would be appreciated. snippets below... void collegeStudent::readSchedule(void) { cout << "-=Student Schedule=-" << endl << endl; cout << numClasses << " number of classes." << endl; //debug for (int x=0;x<numClasses;x++) { cout << "Enter the class name:\n"; cin.ignore(2); //ignores 'fake' buffer input until '\n' gets_s(coursesAndGrades[x].className,30); //I usually have probllems about here... cout << "Enter number of hours this class provides:\n"; cin >> coursesAndGrades[x].hours; cout << "Enter your letter grade in this class:(A-F)\n"; cin >> coursesAndGrades[x].grade; } }
****************************C:DOSC:DOSRUN..RUNDOSRUN-kkuhl86

This topic is closed to new replies.

Advertisement