Jump to content
  • Advertisement
Sign in to follow this  
kkuhl86

Buffer Help!

This topic is 4501 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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; } }

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!