Guardian C Library Calls Reference Manual
fprintf
3-54 128833—Guardian TNS C Library Calls Reference Manual
Reference to Library Calls
Example
In this example, the fprintf function fetches an argument, converts it to a character
string, and then prints it to the file $a.b.c:
#include <stdioh>
FILE *fp;
char *x;
fp = fopen("$a.b.c", "w");
/* ... */
x = "Carolyn";
fprintf(fp, "Hello, %s", x);
n
stores the number of characters printed thus far in the variable of type int that
is referenced by the argument. The argument must have type pointer to int.
o
formats an int argument as an unsigned octal integer.
p
formats the value of a pointer to void argument using the format specified by
the x conversion code.
s
formats the data referenced by a pointer to char argument as a string of
characters. fprintf prints characters from the data until it encounters a null
character or until it has printed precision characters.
u
formats an int argument as an unsigned decimal integer.
x
formats an int argument as an unsigned hexadecimal integer, using the
lowercase letters a through f to represent the digits 10 through 15.
X
formats an int argument as an unsigned hexadecimal integer, using the
uppercase letters A through F to represent the digits 10 through 15.
%
prints a percent sign; for example:
prints, “Stock went up %d%%\n”, increase);