Thread: How do I display an error message when a user inputs nothing

  1. #1
    Registered User
    Join Date
    Mar 2006
    Posts
    7

    How do I display an error message when a user inputs nothing

    I have a quick question. I'm making a little craps game, and I have an annoying problem. Whenever a user is asked for input, and inputs nothing, the cursor goes from the input area to the next line. I want to keep this from happening. I've been told it's probably a windows specific thing, but I can't find any info on it anywhere.

    Thanks in advance.

  2. #2
    The Richness... Richie T's Avatar
    Join Date
    Jan 2006
    Location
    Ireland
    Posts
    469
    I'm guessing you're using cin to read in from the user. I suggest
    using cin.getline - if the user just hits enter, the program doesn't
    keep waiting for input - you can reprint the cursor position.
    No No's:
    fflush (stdin); gets (); void main ();


    Goodies:
    Example of fgets (); The FAQ, C/C++ Reference


    My Gear:
    OS - Windows XP
    IDE - MS Visual C++ 2008 Express Edition


    ASCII stupid question, get a stupid ANSI

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to limit user input to a certain number of digits?
    By NewbGuy in forum C Programming
    Replies: 7
    Last Post: 05-08-2009, 09:57 PM
  2. timed user input
    By sainiabhishek in forum C Programming
    Replies: 4
    Last Post: 04-01-2009, 11:59 AM
  3. Confused about case statements
    By veronicak5678 in forum C++ Programming
    Replies: 1
    Last Post: 09-16-2007, 05:19 PM
  4. program is checking for ent when user inputs out?
    By Blizzarddog in forum C++ Programming
    Replies: 1
    Last Post: 04-07-2003, 01:16 PM
  5. comparing user input
    By lambs4 in forum C Programming
    Replies: 5
    Last Post: 12-15-2002, 10:28 AM