Im using an ansi c gcc comiler and im trying to pass a structure variable from a seperate file into the main.c file and when i do i get the errors unidefied symbol 'ts" warning argument 1 is incompatiable with prototype what am i doing wrong?
Code:
int commandLineArguments(int, char**);
int MainMenu(int*);
int main(int argc, char** argv)
{
int x = 10;
TennisStoreType ts;
commandLineArguments(argc, argv);
MainMenu(&x);
return EXIT_SUCCESS;
}
int commandLineArguments(int argc, char **argv)
{
/* makes a local copy of argc and **argv */
FILE *customer, *stock, *logfile;
/* declares a pointer to each file*/
/* test if 4 arguments exist including the exucutable*/
if(argc !=4)
{
printf("please enter 3 cmd arguments!\n");
return 1;
/* stop pocessing*/
}
/* attempt to open and read arg 1*/
customer = fopen(argv[1], "r");
/* check if custome.csv exists*/
if(customer ==NULL)
{
printf("cannot open %s for reading\n", argv[1]);
return 1;
/* can't go on*/
}
/* try to open stock.csv and read it*/
stock = fopen(argv[2], "r");
/* if stock.csv does not exist error*/
if(stock == NULL)
{
printf("cannot open %s for reading\n",argv[2]);
return 1;
/* stop processing*/
}
/* open logfile for reading */
logfile = fopen(argv[3], "r");
/* check if logfile exists*/
if(logfile == NULL)
{
printf("cannot open %s for reading\n", argv[3]);
return 1;
/* stop processing*/
}
/* close all files */
fclose(customer);
fclose(stock);
fclose(logfile);
return 0;
}
int MainMenu(int *a)
{
int choice = 0;
/* declare variables*/
/* keep doing this until its not equal to 9*/
do
{
printf("\n\t*****Main Menu:\t*****\n");
printf("1) Add Customer\n");
printf("2) Add Stock\n");
printf("3) Delete Record\n");
printf("4) Display Customer\n");
printf("5) Display stock\n");
printf("6) Make Sale\n");
printf("7) Sales Log\n");
printf("8) Save and Exit\n");
printf("9) Abort\n");
printf("Select Your option (1-9):\n");
fscanf(stdin, "%d",&choice);
/* User Input */
readRestOfLine();
/* flushes the stdin buffer for better input*/
/* switch statement to select function*/
switch(choice)
{
case 1:
printf("Add stock");
addCustomer(&ts);
/* i want to pass it into addCustomer somehow*/
break;
}
}
while(choice !=9);
/* end of do while */
/* switch case */
/* do while
/* while !=10 */
return 0;
}
/* then in the second file which contains all the menu option functions such as addCustomer*/
void addCustomer(TennisStoreType* ts)
{
printf("It better call this function!");
}