7 unsigned long int money = 0;
8 unsigned long int num_items = 0;
9 uc num_credit_items = 0;
10 unsigned long int items_sold = 0;
11 struct status_t status[MAX_ITEMS+1];
12 struct credits_t credits[MAX_CREDIT_ITEMS+1];
22 f = fopen("items", "r");
23 for (num_items=0; num_items < MAX_ITEMS && !feof(f); num_items++) {
25 sep = strchr(line, '=');
26 strncpy(status[num_items].item_name, line, sep-line);
27 status[num_items].price = atoi(sep+1);
28 status[num_items].times_sold = 0;
34 * must be called after load_items()
41 f = fopen("state", "r");
43 printf("cannot open state\n");
48 sep = strchr(line, '=');
49 *(line + (sep-line)) = 0;
50 for (i=0; i< MAX_ITEMS; i++) {
51 if (strcmp(line, status[i].item_name)==0) {
52 status[i].times_sold = atoi(sep+1);
71 strcpy(status[0].item_name, "cola");
72 status[0].price = 230;
73 status[0].times_sold = 0;
74 strcpy(status[1].item_name, "mate");
75 status[1].price = 150;
76 status[1].times_sold = 0;
77 for (c = 2; c < MAX_ITEMS; ++c)
78 status[c].item_name[0] = 0;
82 status[0].times_sold=23;
83 status[1].times_sold=42;
92 void save_credits() {}