hey, Im not good with this stuff. Im writing this program in C and it gives me some errors, and I cant figure out how to solve it when it gives me those errors:
Code:
#include "lab10.h"
int main(void)
{
int response;
int count;
string words[MAX_COUNT];
/* your code goes here */
while(1)
{
response = showMenu();
switch(response)
{
case 0: return; /* your code goes here */
break;
case 1: count = inputWords(string words[]);
break;
case 2: displayWords(int count,string words[]);
break;
} /* end of switch */
} /* end of while */
} /*end main */
int showMenu(void)
{
int response;
/*make this printf function complete to display the whole menu*/
printf(" Main Menu\n"
" ---------\n"
" 1. Input words\n"
" 2. Display words\n"
" 3. Search for an exact match\n"
" 4. Search for a partial match\n"
" 5. Calculate the average length\n"
" 0. Exit\n");
printf("\n Please enter a choice: ");
/* use a scanf here to read users response from keyboard */
scanf("%i", &response);
return response;
}
int inputWords(string words[])
{
FILE * ptr;
int count; /*declare and initialize the variable count*/
ptr = fopen("illini.txt","r");
/*copy the code for the loop as shown in lab10 instructions*/
while( EOF != fscanf(ptr,"%s", words[count]))
++count;
return count;
/* Remember to change this return statement below to actually return the value of count.*/
/* Also don't forget to update case 1: in main. */
}
void displayWords(int count,string words[])
{
int i;
for(i=0; i < count ;++i)
printf("%s\n", words[i]);
}
compiler gives me this error:
Code:
lab10.c: In function 'main':
lab10.c:19: error: expected expression before 'string'
lab10.c:21: error: expected expression before 'int'
lab10.c:21: error: too few arguments to function 'displayWords'
I know in which lines is the problem, but i don't know how to fix it. I don't know what to do. any help would be appreciate it.