-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen_customers.c
51 lines (44 loc) · 1.56 KB
/
gen_customers.c
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
typedef struct customer{
char cardId[9];
int state;
char name[21];
char pin[7];
long long balance;
char telNumber[16];
char address[41];
struct customer * next;
} Customer;
int main() {
char *filename1="customer.dat";
char *alphabet="0123456789abcdef";
char *prefix="flag{";
FILE *fptr;
fptr = fopen(filename1,"ab+");
if (fptr == NULL) {
printf("failed to open %s\n", filename1);
exit(1);
}
for (int i = 0; i < strlen(alphabet); i++) {
for (int j = 0; j < strlen(alphabet); j++) {
for (int k = 0; k < strlen(alphabet); k++) {
Customer cust = {0};
strcpy(cust.cardId, prefix);
cust.cardId[5] = alphabet[i];
cust.cardId[6] = alphabet[j];
cust.cardId[7] = alphabet[k];
strcpy(cust.name, cust.cardId);
strcpy(cust.pin, "111111");
strcpy(cust.telNumber, "1800hackers");
strcpy(cust.address, "localhost");
fseek(fptr, 0L, SEEK_END);
fwrite(&cust,sizeof(Customer),1,fptr);
}
}
}
fclose(fptr);
return 0;
}