您的位置:首页 > 其它

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);

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: