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("please input c2:\n");
scanf("%s",c2);
fprintf(fp,"%s",c2);
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);