SilverScreen Solid Modeler

fscanf

fscanf

Previous topic Next topic  

fscanf

Previous topic Next topic JavaScript is required for the print function  

StandardCLibrary

int fscanf( FILE *fp, char *fmt, ... )

 

FILE *fp;         /* stream pointer */

char *fmt;        /* format string */

 

 

 




Synopsis

#include "stdio.h"

 

The fscanf function reads from stream fp under control of format string fmt , and assigns converted values into subsequent arguments, each of which must be a pointer.

 

 

Parameters

fp is a stream pointer, open for input. fmt is a null-terminated string, containing format conversion specifications. Conversion specifiers take the following form:

 

    %[flags][minimum field width][precision][size specification][conversion]

 

where:

 

    flags

zero or more flag characters (-, +, 0, #, or space), (see below)

    minimum field width

optional, a decimal constant, or *

    precision

optional, a period optionally followed by a decimal constant

    size specification

optional, one of l, L or h

    conversion

one of c, d, e, E, f, g, G, i, n, o, p, s, u, x, X or % (see below)

 

Flags:

 

Flag

Meaning

-

left justify the value within field width

+

Always produce a sign, either + or -

0

Use 0 for pad character, not space

#

Use a variant conversion

space

Always produce either the sign - or a space

 

Conversion specifiers:

 

Char

Data type

Meaning

c

int

character conversion

d

int

signed decimal conversion

e

double

signed decimal floating point conversion

E

double

signed decimal floating point conversion

f

double

signed decimal floating point conversion

g

double

signed decimal floating point conversion

G

double

signed decimal floating point conversion

i

int

signed decimal conversion

n

int *

writes the number of characters output so far into an integer pointer

o

int

unsigned octal conversion

p

void *

pointer conversion

s

char *

string conversion

u

int

unsigned decimal conversion

x

int

unsigned hexadecimal conversion

X

int

unsigned hexadecimal conversion

%

none

a single percent sign is output

 

 

Return Value

fscanf returns EOF (-1) if end of file or error occurs before any conversion; otherwise it returns the number of items converted and assigned.

 

 

See Also

sscanf , fprintf