previous | start | next

C scanf Function

The first argument to scanf is a "format" string.

It can contain 1 or more format specifiers, each of which begins with a % followed by a conversion letter.

   Format          Converts
   Specifier       Input String to
      %c           a single character     
      %d           a decimal integer      
      %i           an integer             
      %f           a floating-point number 
      %lf          a double               
      %o           an octal number        
      %s           a string               
      %x           a hexadecimal number    
   

Subsequent arguments must be addresses of variables where the converted value will be stored.

The return value is the number of successful conversions.

For each format specifier scanf function skips over leading white space in the input looking for a beginning character that is valid for the format specifier.

For each format specifier, the scanf stops reading input if trailing space or end of file is detected.



previous | start | next