having problems with cin "go figuere :)"
-
ok... in this code... you dont have to worry where everything is being defined or what headers im using,... wheres my functions... this is just the main program... It all works the first time through, then, the cin stops working: int main() { for(;;)//main loop { gets(SName); cin >> SGPA; person.SetName(SName); person.SetGPA(SGPA); cout << person.GetName() << endl << endl; //print name that you just typed. for(int inc = 0;inc < NN;inc++) //print all names. { cout << Names[inc] << "\t" << GPAS[inc] << endl; } inc = 0; }//end main loop. return 0; } in the program is waits for input for the name of sombody... then it goes on to the next thing... which is my cin statment, asking for the float "GPA" of the persons name you put in. after the first time you run through the on going loop... your not able to insert a GPA, rather, for every new name you put in... it applies the original GPA to the names. Q~How do i reset my cin or get it to work everytime in the loop. set it to null? Thanks! ~SilverShalkin :rose: i have a fealling that it might not be the cin :(, but i'll see in a bit :)
-
ok... in this code... you dont have to worry where everything is being defined or what headers im using,... wheres my functions... this is just the main program... It all works the first time through, then, the cin stops working: int main() { for(;;)//main loop { gets(SName); cin >> SGPA; person.SetName(SName); person.SetGPA(SGPA); cout << person.GetName() << endl << endl; //print name that you just typed. for(int inc = 0;inc < NN;inc++) //print all names. { cout << Names[inc] << "\t" << GPAS[inc] << endl; } inc = 0; }//end main loop. return 0; } in the program is waits for input for the name of sombody... then it goes on to the next thing... which is my cin statment, asking for the float "GPA" of the persons name you put in. after the first time you run through the on going loop... your not able to insert a GPA, rather, for every new name you put in... it applies the original GPA to the names. Q~How do i reset my cin or get it to work everytime in the loop. set it to null? Thanks! ~SilverShalkin :rose: i have a fealling that it might not be the cin :(, but i'll see in a bit :)
cin.flush() should solve your problems, I reckon. Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little. And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002