leo*_*loy 12
正如其他评论者所指出的那样(并且从文档中可以明显看出),最大的区别在于printf允许参数的格式化.
也许您在询问函数是否相等而没有传递其他参数printf()?好吧,他们不是.
char * str;
FILE * stream;
...
fputs(str,stream); // this is NOT the same as the following line
fprintf(stream,str); // this is probably wrong
Run Code Online (Sandbox Code Playgroud)
第二个可能是错误的,因为字符串参数fprintf()仍然是一个格式化字符串:如果它具有'%'字符,它将被解释为格式化说明符.
功能相当(但不那么直接/有效/好)的形式
fprintf(stream,"%s", str);
Run Code Online (Sandbox Code Playgroud)
嗯...... puts()只是写一个字符串,同时printf()为几种类型的数据提供了许多格式化工具.
fputs()
http://www.cplusplus.com/reference/clibrary/cstdio/fputs/
fprintf()
http://www.cplusplus.com/reference/clibrary/cstdio/fprintf/
文档很有用!学习阅读它,你将拥有一个强大的工具.
| 归档时间: |
|
| 查看次数: |
46281 次 |
| 最近记录: |