cin >> flush;
To clear the input stream in C++ use cin.ignore() everytime you think the input stream may still have data in it.
cout<<"Enter your name"<cin.getline(name, 50, '\n'); //ignore not needed, getline does it
cout<<"Enter your age"<cin>>age; cin.ignore(); //clear the newline from the stream
cout>>"Enter your height"<cin>>height; //this will work now
No comments:
Post a Comment