函数名: fprintf
功 能: 传送格式化输出到一个流中
用 法: #include <stdio.h>
int fprintf(FILE *stream, char *format[, argument,...]);
程序例:
/* Program to create backup of the
AUTOEXEC.BAT file */
#include <stdio.h>
int main(void)
{
FILE *in, *out;
if ((in = fopen("\\AUTOEXEC.BAT", "rt"))
== NULL)
{
fprintf(stderr, "Cannot open input \
file.\n");
return 1;
}
if ((out = fopen("\\AUTOEXEC.BAK", "wt"))
== NULL)
{
fprintf(stderr, "Cannot open output \
file.\n");
return 1;
}
while (!feof(in))
fputc(fgetc(in), out);
fclose(in);
fclose(out);
return 0;
}