FILE *p=fopen("f:\\xxk\\lianxi.txt","w");
这个你是想读取文件的吧,改成
FILE *p=fopen("f:\\xxk\\lianxi.txt","r");吧。
下面是msdn的说法,w 如果文件存在,内容会被清空
"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 end-of-file (EOF) marker before new data is written to the file. Creates the file if it does not exist.
"r+"
Opens for both reading and writing. The file must exist.
"w+"
Opens an empty file for both reading and writing. If the 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. The EOF marker is not restored after writing is complete. Creates the file if it does not exist.