hi,
Just c the code below:
in the second "for" loop moving "cin. get" after cout<< ratings(i.e deleting the cin.get above cout and adding cin after cout) changes the way output looks.Code:int main() { vector<int> ratings(5); for(int i=0; i<5; i++) { cout<< "enter rating:"; cin >> ratings[i]; } for(i=0; i<5; i++) { cin.get(); cout<< ratings[i]; // cin.get(); } }
In the first case (when cin.get is above cout) the ratings are displayed one after the other on hitting the enter key. In the second case(when cin.get is after cout) if I enter rating say, 1,2,3,4,5 then the output shows 12 and then waits for the enter key.
Why shud this happen??
Best Regards,
Shal



LinkBack URL
About LinkBacks


