int fprintf (FILE* stream, const char*format, [argument])
其中,FILE*stream为文件指针,const char* format以什么样的格式输出,[argument]为输入列表
#include <stdio.h>
int main()
{
FILE* fp;
int i = 617;
char* s = "that is a good new";
fp = fopen("text.dat", "w");
fputs("total", fp);
fputs(":", fp);
fprintf(fp, "%d\n", i);
fprintf(fp, "%s", s);
fclose(fp);
return 0;
}
输出
1
2
total:617
that is a good new