Thread: Problem with char

  1. #1
    Registered User
    Join Date
    Feb 2012
    Posts
    4

    Problem with char

    Hey, I'm new to C programming and am having trouble reading in characters from the keyboard. When I call the function (below), I can enter three characters before the compiler skips to the next part of my program. I know it should be very basic, but I'm not sure if its a problem with my laptop.

    Code:
    void char_test() {
        char a, b, c, d, e, f;
        
        scanf("%c",&a);
        scanf("%c",&b);
        scanf("%c",&c);
        scanf("%c",&d);
        scanf("%c",&e);
        scanf("%c",&f);
    }
    I've simplified it as much as I can to try to figure it out myself.

    Any help would be much appreciated.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Each one of those says to enter 1 character at a time. The enter key counts as one character.


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Feb 2012
    Posts
    4
    Wow, thank you.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Basic char */const char* problem
    By wisuzu in forum C++ Programming
    Replies: 7
    Last Post: 12-02-2011, 11:56 AM
  2. Replies: 9
    Last Post: 08-09-2011, 12:41 PM
  3. Conversion Char To Char * Problem
    By ltanusaputra in forum Windows Programming
    Replies: 3
    Last Post: 03-01-2008, 02:06 PM
  4. Problem with char and char*
    By chris1985 in forum C Programming
    Replies: 1
    Last Post: 05-08-2005, 11:44 AM
  5. char problem
    By ForlornOdium in forum C++ Programming
    Replies: 10
    Last Post: 10-29-2003, 02:39 PM

Tags for this Thread