the usage(head file and other) of sprintf(), fprintf()
2016-02-17 18:22
399 查看
sprintf() is for string, while fprintf() is for file.
#include <stdio.h>
int main(void)
{
int a = -100;
FILE *fp;
unsigned char str[10];
sprintf(str, "%d", a); // str is string ptr.
printf("str: %s\n", str);
fp = fopen("/tmp/fprintf.txt", "w+");
fprintf(fp, "%s\n", str); // fp is a file ptr.
fclose(fp);
}
#include <stdio.h>
int main(void)
{
int a = -100;
FILE *fp;
unsigned char str[10];
sprintf(str, "%d", a); // str is string ptr.
printf("str: %s\n", str);
fp = fopen("/tmp/fprintf.txt", "w+");
fprintf(fp, "%s\n", str); // fp is a file ptr.
fclose(fp);
}
相关文章推荐
- MAC地址漂移经典案例分析
- 深入理解Linux内核 Chapter1知识点
- ListView 列表显示
- 02:输出最高分数的学生姓名(1.9)
- B. Grandfather Dovlet’s calculator
- Android正则验证手机号,身份证号,邮箱等格式是否正确
- Xcode插件管理工具Alcatraz
- 【设计模式】6、适配器模式
- 关于java面试
- hibernate4之一对一关系映射(二)
- Android MTK平台修改开关机动画和开机logo
- HDU 2159 FATE(全然背包+二维费用背包)
- 欢迎使用CSDN-markdown编辑器
- 安卓应用内重启
- java连接sftp服务+linux配置
- QT tableview用法
- 利用网线连接两台电脑
- SQL DISTINCT 多字段查询用法
- Hash算法
- 不同场景下 MySQL 的迁移方案