FILE *fp;
char c1[512];
char c2[512];
int i=0;
if((fp=fopen("/路径",'r'))=NULL)
printf("cant open the file");
//读出文件内容并显示
while(!feof(fp))
{
c1[i++]=fgetc(fp);
}
printf("%s\n",c1);
fclose(fp);
//向文件内写内容
if((fp=fopen("/路径",'w'))=NULL)
printf("cant open the file");
printf("please input c2:\n");
scanf("%s",c2);
fprintf(fp,"%s",c2);
fclose(fp);
追问头文件之类的不用加吗?