beautypg.com

Zilog EZ80F916 User Manual

Page 380

background image

UM014423-0607

C Standard Library

ZiLOG Developer Studio II

eZ80Acclaim!

®

User Manual

360

conversion result. If this object does not have an appropriate type, or if the result of
the conversion cannot be represented in the space provided, the behavior is undefined.

NOTE: See “scanf Conversion Characters” for valid input information.

Synopsis

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

Returns

The value of the macro EOF if an input failure occurs before any conversion. Otherwise,
the

scanf

function returns the number of input items assigned, which can be fewer than

provided for, or even zero, in the event of an early conflict between an input character and
the format.

Examples

int i
scanf("%d", &i);

The following example reads in two values.

var1

is an

unsigned

char

with two decimal

digits, and

var2

is a

float

with three decimal place precision.

scanf("%2d,%f",&var1,&var2);

scanf Conversion Characters

d

Matches an optionally signed decimal integer, whose format is the same as expected for
the subject sequence of the strtol function with the value 10 for the base argument. The
corresponding argument is a pointer to integer.

i

Matches an optionally signed integer, whose format is the same as expected for the
subject sequence of the strtol function with the value 0 for the base argument. The
corresponding argument is a pointer to integer.

o

Matches an optionally signed octal integer, whose format is the same as expected for the
subject sequence of the strtol function with the value 8 for the base argument. The
corresponding argument is a pointer to integer.

u

Matches an unsigned decimal integer, whose format is the same as expected for the
subject sequence of the strtol function with the value 10 for the base argument. The
corresponding argument is a pointer to unsigned integer.

x

Matches an optionally signed hexadecimal integer, whose format is the same as expected
for the subject sequence of the strtol function with the value of 16 for the base argument.
The corresponding argument is a pointer to integer.

e,f,g

Matches an optionally signed floating-point number, whose format is the same as
expected for the subject string of the strtod function. The corresponding argument is a
pointer to floating.

This manual is related to the following products: