木槿巴巴

[BUG]读写文件-打开正常,无法读写

问题已经描述,请思考,其实可能很深很深……

FILE *fp;
char File_Name[]="sFile_Name";
int Func( char ** args)
{
fp=fopen(File_Name,"w");
frprintf(fp,"Writing somthing.");
SubFunc_1(args);
SubFunc_2(args);
/* do sothing */
/* ......... */
}


static int SubFunc_2(char **args)
{
if ((fp = fopen(File_Name, "rb")) == NULL)
{
return -1;
/* sorry ,It is all OK. */
}
while (fgets(sBuf, sizeof(sBuf), fp) != NULL)
{
/*opps...Null...*/
}
}

Exit mobile version