Dev C++ Entering User Inputs

Hello all,

User Input: Strings and Numbers C 12 Years Ago John A 1,896. User input/output is a key component in the programs you write, yet most online tutorials just provide a quick-and-dirty method of grabbing data. In other words, it works right up until the point the user does something unexpected.

Dev

C++ User Input String

I've tried reading back threads and the various posted tutorials, etc that here and I've not stumbled upon the answer I'm looking for.

I am attempting to write a hangman game as a school project, and I am having trouble getting just one character from the input stream. This is the code I have so far:

Its pretty ugly, but it works ok. I don't yet know how to code something better (which is what I'm trying to find out). The original idea that I had was to read the text stream from the user into an array declared to size of 1, ignoring all other characters after the first character so as not crash the program.

There HAS to be a better way of doing this. I've read about the get function at cplusplus.com. cplusreference.com, and I've googled the net but I've come up with nada. If someone would be so kind as to help me with this, I (and my teammates for this program) would appreciate it.

C++ Validating User Input

Thanks

  • 6 Contributors
  • forum 7 Replies
  • 3,865 Views
  • 20 Hours Discussion Span
  • commentLatest Postby SalemLatest Post
C++

darkagn315

I'm pretty sure this should work:

C++ Int User Input

Entering

C++ User Input Read File

I haven't tried it, but it only allows for a one character input I think...