if i want user to enter a single char in a variable...then how to restrict him/her from typing more than 1 character.....??

Recommended Answers

All 3 Replies

I guess you best bet would be to use getline

You can't keep the user from typing on the keyboard but you can remove all remaining keys from the keyboard input buffer. If you are using c++ cin then read this thread to find out how to flush the input buffer.

thank you....that works......

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.