Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Fun with streams

This topic is 5560 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

int main(void)
	int temp;

	cout<<"Press a key to continue"<<endl;


	cout<<"And Again"<<endl;

	cout<<"O.K. now for a change, press a key"<<endl;

	cout<<"Why didn''t input get blocked on this line?"<<endl;

        return 1;
Can anybody tell me why getchar() doesn''t block input after using cin, and how to remedy the situation

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
The cin is probably leaving the \n inside the input stream (which is put in when you press enter), and so the getchar() just retrieves the \n and doesnt block

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!