这次有了fprintf()也可以加深一下刚才的格式化读,小例子:
#include <stdio.h> FILE *stream; void main() { int i = 10; double fp = 1.5; char s[] = "this is a string"; char c = '\n'; stream = fopen("fprintf.out","w"); fprintf(stream, "%s%c", s, c); fprintf(stream, "%d\n", i ); fprintf(stream, "%f\n", fp ); fclose(stream); }
[root@localhost gcc]# ./a.out [root@localhost gcc]# cat fprintf.out this is a string 10 1.500000 [root@localhost gcc]#作为一个在底层开发的人来说,这些稀奇古怪有什么用呢?有用没用先学着吧,大概有个印象,以后有用再来翻。