#include <stdio.h>
#include <fcntl.h>
int main(void)
{
int fp = -1;
FILE *fp2 = NULL;
char a[10] = "123\n";
fp = open("./9.txt",O_RDWR|O_CREAT);
if (-1 == fp)
{
perror("open fail:");
}
fp2 = fdopen(fp,"w");
if (NULL == fp2)
{
perror("error num:");
}
fwrite(a,sizeof(char),sizeof(a),fp2);
fclose(fp2);
close(fp);
return 0;
}
请问fclose和close都需要吗?为什么