为什么写不入文件?
int MyFile;int LoanNumber,i;
// Assigning the file path to a string
char FileName = "E:\\TestProj\\Award\\test.txt";
// Opening the file
// Note the use of variable to replace the file path
//
MyFile = (int)fopen(FileName,"w");
// Reading and printing one loan number at a time
for(i=1;i<=5;i++)
{
fscanf(MyFile,"%d", &LoanNumber);
lr_output_message("Loan Number %d: %d",i,LoanNumber);
}
fclose(MyFile);
return 0; Long MyFile;
int LoanNumber,i; //不知道LoanNumber是从什么地方获取的,也许有其他的脚本,到打印的时候也没有赋值
char *FileName = "E:\\TestProj\\Award\\test.txt";
MyFile = fopen(FileName,"a+");
for(i=1;i<=5;i++)
{
fprintf(MyFile,"%d", &LoanNumber);
lr_output_message("Loan Number %d: %d",i,LoanNumber);
}
fclose(MyFile);
//这样应该就没问题了吧 你用错函数了
Long MyFile;
int LoanNumber,i; //不知道LoanNumber是从什么地方获取的,也许有其他的脚本,到打印的时候也没有赋值
char *FileName = "E:\\TestProj\\Award\\test.txt";
MyFile = fopen(FileName,"a+");\\The type fo access mode: r, w, a or r+, w+, a+, where the "+" sign
// indicates that the file must already exist.
for(i=1;i<=5;i++)
{
fprintf(MyFile,"%d", LoanNumber);
lr_output_message("Loan Number %d: %d",i,LoanNumber);
}
fclose(MyFile);
他要那个变量的地址没有用吧 我想他是想把写入的数据在通过lr_output_message显示出来个人建议
[ 本帖最后由 gnixougil 于 2009-11-12 14:14 编辑 ] a+ 不能用? 没看明白你的意思 a+ 不能用? 没看明白你的意思
1楼函数用错了那个是输出不输入
页:
[1]