I am having a problem getting my program to compile. Can someone please see if they can get this to compile?
Thanks
Code:
#include <stdio.h>
struct stack
{
int* store;
int top;
int capacity;
};
struct queue
{
int* store;
int front;
int back;
int capacity;
};
struct employee
{
int id;
int* tray;
};
struct stack* createStack(); //Stack
struct queue* createQueue(); //Queue
struct queue* newEmployee();
int main (void)
{
FILE* fin;
FILE* fout;
char fname[1024]; //name of the input file we are reading from
char output[1024]; //name of the output file we are writing to
char letter; // the character determines what happens
int num; //variable for the number of lines to follow
int count = 0; //variable for the minute that we are on
int j, k;
int temp;
int newEmployee;
int incompetence = 0;
printf("Welcome to Cafeteria in Latveria!\n");
//Ask user for the name of the file to read from
printf("Please enter the name of the file you wish to read from: \n");
//Read in the file to read from
scanf("%s", fname);
//Open file for reading
fin = fopen(fname, "r");
//Check to make sure the file exists and opens correctly, if not display
//an error message to the user
if(fin == NULL)
{
printf("Unable to open the file %s\n", fname);
system("PAUSE");
return 0;
}
fscanf(fin, "%d ", &num);
// Ask the user to specify and output file name
printf("What is the name of the file you wish to save?\n");
scanf("%s", output);
//Open the specified file
fout = fopen(output, "w");
struct stack* stack = createStack();
struct queue* q = createQueue();
// struct employee e = newEmployee();
//Operation
for(count = 1; count < num; count++)
{
fprintf(fout, "Minute %d: ", count);
if(!feof(fin))
{
fscanf(fin, "%c ", &letter);
// Dispensing
if(letter == 'D')
{
incompetence = dispense(stack, q);
if(incompetence == 1)
break;
}
// Trays
else if(letter == 'T')
{
fscanf(fin, "%d ", &j);
for(k = 0;k < j; k++)
{
fscanf(fin, "%d ", &temp);
push(stack, temp);
}
fprintf(fout, "%d trays were added to the dispenser. The topmost tray is %d \n", j, getTop(stack));
}
// Employee
else if(letter == 'E')
{
fscanf(fin, "%d ", &j);
for(k = 0;k < j; k++)
{
fscanf(fin, "%d ", &temp);
newEmployee = malloc(sizeof(struct employee));
newEmployee->id = temp;
newEmployee->tray = -1;
enqueue(queue, newEmployee);
}
fprintf(fout, "%d people entered the line. \n", j );}
}
continue;
}
if(queueEmpty(queue))
{
fprintf(fout, "Lunchtime is over. Long live our Fearless Leader!\n");
break;
}
// When the queue is empty you reads the statement above
// Otherwise dispenser will be empty and you are incompetent!!
incompetence = dispense(stack, queue);
if(incompetence == 1)
break;
}
// This is used to print out information to the saved file..
// fprintf(fout, "Sample");
//Close the input and output files
fclose(fin);
fclose(fout);
system ("PAUSE");
return 0;
}
//Create a new stack
struct stack* createStack()
{
struct stack* s;
s = malloc(sizeof(struct stack));
s->store = calloc(999, sizeof(int));
s->top = 0;
s->capacity = 999;
return s;
}
struct queue* createQueue()
{
struct queue* q = malloc(sizeof(struct queue));
q->store = calloc(99, sizeof(int));
q->front = 0;
q->back = 0;
q->capacity = 99;
return q;
}
struct queue* newEmployee();
{
struct queue* newEmp = malloc(sizeof(int));
return newEmp;
}