#include <stdio.h>
struct clientDate {
int account;
char firstName[15];
char lastName[10];
float money;
};
main()
{
struct clientDate bankDate = {0, "", "", 0.0};
FILE *cPtr;
int i;
if((cPtr = fopen("credit.dat", "w")) == NULL)
printf("File can't be opened!\n");
else { for(i = 1; i <= 100; i++) {
fwrite(&bankDate, sizeof(struct clientDate), 1, cPtr);
fprintf(cPtr, "\n");
}
}
fclose(cPtr);
}
输出的文本如图
struct clientDate {
int account;
char firstName[15];
char lastName[10];
float money;
};
main()
{
struct clientDate bankDate = {0, "", "", 0.0};
FILE *cPtr;
int i;
if((cPtr = fopen("credit.dat", "w")) == NULL)
printf("File can't be opened!\n");
else { for(i = 1; i <= 100; i++) {
fwrite(&bankDate, sizeof(struct clientDate), 1, cPtr);
fprintf(cPtr, "\n");
}
}
fclose(cPtr);
}
输出的文本如图