Jump to content
  • Advertisement


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


Fun with streams

This topic is 5480 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.

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!