c语言fprintf突然间不好使了

请看这段代码,执行完全没问题,就是fprintf无法写入到文件。。。但之前读取这个文件一点问题都没有。。。

else if (kind==1)
{
custaccF=fopen("c:\\Support\\custacc.txt","a");
do
{
gets(clear);
printf("Please enter your account, if it is your 1st time, we will create one:\n");
gets(account);
if (iscustacc(account)==FALSE)
{
printf("\nAccount does not exist, type in your password to create one.\n");
printf("Please enter your password:\n");
gets(password);
fprintf(custaccF,"%s %s\n",account,password);
printf("\nYour account is successfully created!");
strcpy(customer,account);

right=TRUE;
kind=0;
break;
}
else
{
printf("\nPlease enter your password:\n");
gets(password);
if(custvalid(password)==FALSE)
{
printf("\nWrong Account-Password Combination.(press 'enter' to continue)\n");
continue;
}
else
{
right=TRUE;
kind=0;
break;
}
}
} while (isvalid(password)==FALSE);
}
问题已解决,不知道怎么弄得就好使了(我没进行任何修改。。。= =)。。。

a 以附加的方式打开只写文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾,即文件原先的内容会被保留。(EOF符保留)
a+ 以附加方式打开可读写的文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾后,即文件原先的内容会被保留。 (原来的EOF符不保留)

custaccF=fopen("c:\\Support\\custacc.txt","a");

改成"a+"试试追问

试过了,没有用。。。TT

温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-09-04
没有fclose吗