Just receive numbers (0-9) as input.

This is a discussion on Just receive numbers (0-9) as input. within the C Programming forums, part of the General Programming Boards category; I tried something like that: Code: //Receive the max questions of the game //Receive the max questions of the game ...

  1. #1
    Registered User Vber's Avatar
    Join Date
    Nov 2002
    Posts
    807

    Just receive numbers (0-9) as input.

    I tried something like that:

    Code:
    //Receive the max questions of the game
        //Receive the max questions of the game
        do {
        printf("\nHow Many questions at all game? (I.E: 10)\n");
        scanf("%d",&max_questions); } while(isdigit(max_questions) != 0);
    But he receives letters too, and this causes a big problem on my App, whats wrong here?

    I dont know too much about isdigit(), I think he return 1+ when is just numbers and 0 when its an char, right?

    Someone can help? this seems to be easy for those who knows
    Thanks!!!!

  2. #2
    Registered User Vber's Avatar
    Join Date
    Nov 2002
    Posts
    807

    I didnt understood you too much..

    I want to use isdigit(), I think the problem is that I need to send an char for isdigit instead int, right?

    or maybe because I didnt wrote well the do...while loop.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. entering numbers to array in a row whithout length input
    By transgalactic2 in forum C Programming
    Replies: 55
    Last Post: 01-02-2009, 04:02 AM
  2. For loop problems, input please.
    By xIcyx in forum C Programming
    Replies: 2
    Last Post: 04-22-2007, 04:54 AM
  3. I would love some input on my BST tree.
    By StevenGarcia in forum C++ Programming
    Replies: 4
    Last Post: 01-15-2007, 01:22 AM
  4. About aes
    By gumit in forum C Programming
    Replies: 13
    Last Post: 10-24-2006, 04:42 PM
  5. Can we input negative numbers in the output windiw
    By hitesh1511 in forum C Programming
    Replies: 1
    Last Post: 08-22-2006, 01:07 AM

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