int main()
{ char c,*d;
int m=0;
FILE *p;
p=fopen("2.txt","r+");
for(;(c=getc(p))!=-1;)
{
m+=1;
if(m%5==0)fputc('0',p);
}
fclose(p);
getchar();
}
结果2.txt没变 这是怎么的 谢谢了
"r"
Opens for reading. If the file does not exist or cannot be found, the fopen call fails.
"w"
Opens an empty file for writing. If the given file exists, its contents are destroyed.
"a"
Opens for writing at the end of the file (appending) without removing the EOF marker before writing new data to the file; creates the file first if it doesn’t exist.
"r+"
Opens for both reading and writing. (The file must exist.)
"w+"
Opens an empty file for both reading and writing. If the given file exists, its contents are destroyed.
"a+"
Opens for reading and appending; the appending operation includes the removal of the EOF marker before new data is written to the file and the EOF marker is restored after writing is complete; creates the file first if it doesn’t exist.