我需要将整数打印到文件中。我将在下面发布代码。此代码的输出是一个空文件,它不包含整数。
FILE *out1;
out1 = fopen(outfile, "w");
if( out1 == NULL )
{
perror("Error while opening the output file.\n");
exit(EXIT_FAILURE);
}
int paste = noptr->no;
printf("message received %d\n", paste);
fprintf(out1,"%d\n", paste);
printf("printed!\n");
fclose(out1);