[英]Writing an Int to a file in C
The following code DOES NOT WORK.saids that fprint is not formatted.以下代码不起作用。表示 fprint 未格式化。 any help will be thank, DO not link this to a post already posted.
任何帮助将不胜感激,请勿将此链接到已发布的帖子。 There is not one.
没有一个。 and i can not find a way to make to this write to a file.
我找不到一种方法来写入文件。 it is an int.
它是一个整数。
void print(int number, int readpfd)
{
FILE *out1;
out1 = fopen("outfile.txt","w");
int i;
int f;
char file_name[42];
char cover[42];
for( i = 0; i < number; i++ )
{
read(readpfd, &f, sizeof(int));
fprintf("out1, %d\n", f); //this is the line that wrong
}
close(readpfd);
fclose(out1);
}
This is basic syntax error.这是基本的语法错误。 You can always refer to man pages.
您可以随时参考手册页。 Replace your
fprintf
statement with this.用这个替换你的
fprintf
语句。
fprintf(out1, "%d", f);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.