forked from 24UCS271-MiniProject/miniProjectSourceCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit_credit.c
More file actions
26 lines (24 loc) · 650 Bytes
/
Copy pathinit_credit.c
File metadata and controls
26 lines (24 loc) · 650 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// This program initializes credit.dat with 100 empty clientData records
#include <stdio.h>
#include <stdlib.h>
struct clientData {
unsigned int acctNum;
char lastName[15];
char firstName[10];
double balance;
};
int main() {
FILE *cfPtr;
struct clientData blankClient = {0, "", "", 0.0};
int i;
if ((cfPtr = fopen("credit.dat", "wb")) == NULL) {
puts("File could not be created.");
exit(1);
}
for (i = 0; i < 100; ++i) {
fwrite(&blankClient, sizeof(struct clientData), 1, cfPtr);
}
fclose(cfPtr);
puts("credit.dat initialized with 100 empty records.");
return 0;
}