reading input

This is a discussion on reading input within the C++ Programming forums, part of the General Programming Boards category; I want to do a standard prompt to ask a user to input an integer value and then read this ...

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    14

    Question reading input

    I want to do a standard prompt to ask a user to input an integer value and then read this value and assign it to a unsigned char which I have already initialised so that the unsigned char variable has this value.
    I imagine I use a standard printf for the prompt and if it was a char use scanf and then the get function but how do i do what i need to do stated above??
    thanks

  2. #2
    Registered User
    Join Date
    Aug 2001
    Posts
    155
    as someone who prefer streams over printf()/scanf() you could try this:

    cout << "enter a single numeric digit 0-9" << endl;
    char ch;
    cin >> ch;


    with printf()/scanf() it would be something like this, I think:

    printf("enter a single numeric digit 0-9");
    char ch;
    scanf(%c, &ch);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. can someone help me with these errors please code included
    By geekrockergal in forum C Programming
    Replies: 7
    Last Post: 02-10-2009, 02:20 PM
  2. Need some help with C program writing
    By The_PC_Gamer in forum C Programming
    Replies: 9
    Last Post: 02-12-2008, 09:12 PM
  3. About aes
    By gumit in forum C Programming
    Replies: 13
    Last Post: 10-24-2006, 04:42 PM
  4. Help with linked list (and reading user input)
    By p1kn1c in forum C Programming
    Replies: 2
    Last Post: 04-05-2006, 01:43 AM
  5. Reading input as an integer
    By n0de in forum C++ Programming
    Replies: 4
    Last Post: 04-11-2002, 07:52 PM

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