SilverScreen Solid Modeler

fprintf

fprintf

Previous topic Next topic  

fprintf

Previous topic Next topic JavaScript is required for the print function  

StandardCLibrary

 

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

 

FILE *fp;         /* output stream pointer */

char *fmt;        /* format string */

 

 




Synopsis

#include "stdio.h"

 

The fprintf function writes text to the file associated with fp according to format string fmt . Arguments following fmt are formatted and printed in the output string.

 

 

Parameters

fp is a stream pointer, open for output. fmt is a null-terminated string, containing format conversion specifications. In the processing of fmt , when fprintf encounters a conversion specification, it retrieves an argument and formats it into the output string at that location, replacing the conversion specifier. All other characters are copied into the output string.

Conversion specifiers are introduced in the format string by the percent character '%' . More specifically, 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

z

SS_XYZ *

floating point conversion of a 3D point

%

none

a single percent sign is output

 

 

Return Value

fprintf returns the number of characters printed.

 

 

Comments

The types of arguments must match those expected by the format specifiers in fmt, and the number of arguments must be greater than or equal to the number of specifiers in fmt; otherwise, the result of fprintf is undefined.

 

 

See Also

printf , sprintf , ss_command