Thread: some questions about scanf

  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    32

    some questions about scanf

    I wrote something like this:

    Code:
    int main () {
    
       char input[5];
    
       scanf ("%c" , input);
       scanf ("%c" , input);
       scanf ("%c" , input);
       scanf ("%c" , input);
    
       return 0;
    
    }
    I have 4 scanf there, how come after running the program, it only allows me to input 2 times?

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Time to read this!

    STDIN pitfalls

    "stdin" is the stream scanf reads from, and it is buffered.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. questions....so many questions about random numbers....
    By face_master in forum C++ Programming
    Replies: 2
    Last Post: 07-30-2009, 08:47 AM
  2. Problem with RPC and scanf
    By Ricardo_R5 in forum C Programming
    Replies: 11
    Last Post: 01-08-2007, 06:15 PM
  3. Replies: 2
    Last Post: 02-20-2005, 01:48 PM
  4. scanf to struct pointer
    By ronenk in forum C Programming
    Replies: 11
    Last Post: 12-20-2004, 10:22 AM
  5. questions questions questions.....
    By mfc2themax in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 08-14-2001, 07:22 AM