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

This is a discussion on How do I display an error message when a user inputs nothing within the C++ Programming forums, part of the General Programming Boards category; I have a quick question. I'm making a little craps game, and I have an annoying problem. Whenever a user ...

  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, 10:57 PM
  2. timed user input
    By sainiabhishek in forum C Programming
    Replies: 4
    Last Post: 04-01-2009, 12:59 PM
  3. Confused about case statements
    By veronicak5678 in forum C++ Programming
    Replies: 1
    Last Post: 09-16-2007, 06: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, 02:16 PM
  5. comparing user input
    By lambs4 in forum C Programming
    Replies: 5
    Last Post: 12-15-2002, 10:28 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21