文件的问题
不知道程序哪里出错了, 输入第一组数据的时候编译器(VC++6.0)就会弹出一个错误对话框。。。#include <stdio.h>
typedef struct
{
int account;
char lastName[15];
char firstName[10];
float balance;
} Date;
int main (void)
{
FILE * cfPtr;
Date client;
if ((cfPtr = fopen ("clients.txt", "w+")) == NULL)
printf ("File could be opened.\n");
else
{
printf ("Enter account number"
"(0 to end input): \n");
scanf ("%d", &client.account);
while (client.account != 0)
{
printf ("Enter lastName, firstName, balance:\n");
scanf ("%s%s%f", client.lastName,
client.firstName, &client.balance);
fseek (cfPtr, (client.account - 1) * sizeof (Date),
SEEK_SET);
fwrite (&client, sizeof (Date), 1, cfPtr);
printf ("Enter account number.\n");
scanf ("%d", &client.account);
}
fclose (cfPtr);
}
return 0;
}