I'm not sure what's causing this code to not work. I'm not getting any error messages. It just gives me a blank output. transactiondata is a file that has a list of employees (e), customers (c) and transactions (t). I'm supposed to output a list that shows the transactions, which customers made them with which employees, and how it affected their balance.
#include <stdio.h>
#include <string.h>
int main(int argc, char* argv[])
{
FILE *fpointer = fopen("transactiondata", "r");
if(fpointer == NULL)
{
printf("Error. Could not read file.\n");
return 1;
}
char status, transactionType, eName[30], cName[30], employees[55][30], customers[55][30];
float balances[55], bal, transaction;
int eID, cID;
while(fscanf(fpointer, "%c", &status) != EOF);
{
switch(status)
{
case 'e':
fscanf(fpointer, "%i %s", &eID, eName);
strcpy(employees[eID], eName);
break;
case 'c':
fscanf(fpointer, "%i %s %f", &cID, cName, &bal);
strcpy(customers[cID], cName);
balances[cID] = bal;
break;
case 't':
fscanf(fpointer, "%i %i %c %f", &cID, &eID, &transactionType, &transaction);
if(transactionType == 'w')
{
balances[cID] -= transaction;
transactionType = '-';
}
else
{
balances[cID] += transaction;
transactionType = '+';
}
printf("%10s %10s\t\t%c$%0.2f %8.2f\n", customers[cID], employees[eID],
transactionType, transaction, balances[cID]);
break;
default:
break;
}
}
return 0;
}