Crossware

Table of Contents        Previous topic       Next topic       

C COMPILER LIBRARY FUNCTION REFERENCE->Detailed Descriptions->scanf()

Summary

#include <stdio.h>

int scanf(const char* format, ...);


Parameters

    
formatFormat control string
...Arguments to receive scanned data


Description

This function reads formatted data from the standard input stream stdin and assigns converted values to subsequent arguments, each of which must be a pointer.  The function returns when format is exhausted.

The format control string contains the following types of objects:
    

A conversion specification determines the conversion of the next input field.  Normally the result is placed in the variable pointed to by the next argument that has not received a conversion result but it the assignment suppression character has been used, then the input field is skipped and no
assignment is made.

The integer conversion characters d, i, o, u  and x may be preceded by h if the argument is a pointer to a short integer and l if the argument is a pointer to long integer.

The floating point conversion characters e, f and g may be preceded by l if the argument is a pointer to double and L if the argument is a pointer to long double.


The conversion characters allowed are:
    
CharacterArgumentInput Data
Type
    
dint *Decimal integer.
Iint *Integer. The integer may be octal (leading 0) or hexadecimal (leading 0x or 0X).
oint *Octal integer (with or without a leading zero).
xint *Hexadecimal integer (with or without a leading 0x or 0X).
uunsignedUnsigned decimal integer.
int *
cchar *Character.  The next x input characters are placed in the argument array, where x is the value of the field width or 1 if no field width is given.  The normal skip white space characters is suppressed.
schar *String.  The argument points to an array of characters which should be large enough to hold the string and a terminating '\0' that will be added.
e,f,gfloat *Floating point value consisting of an optional sign (+ or -), a series of one or more decimal digits containing a decimal point and an optional exponent (e or E) followed by an optional signed integer value.


Return Value

The function returns the number of fields successfully converted and assigned.