When I am trying to call a function, the parameters that I have tried so far have just resulted in the terminal saying that 'too few arguments to function' and what I can tell that it wants written there is the parameters from when it was declared. I have read a few different documents about this and what the calling parameters are and the different between calling by value or by reference but I am still not able to figure out the problem.
Below is the main section of code that has the call functions in it along with some variables.
Code:
int main(int argc, char *argv[])
{//main()
char *listwords;
processfile(listwords); //<- this is the line that is causing the problem
WordList mylist;
initialiselist(&mylist);
addword(&mylist, createfillednode(listwords));
printlist(&mylist);
}//main()
Code:
//process the file
void processfile(WordList *wordList, int argc, char *argv[])
{//process file
//file pointer
FILE *f;
//open the file
f = fopen(argv[1], "r");
//check it opened correctly
if(f == NULL)
{//if statement
printf("cannot read file\n");
}//if statement
fseek(f, 0, SEEK_END);
//declare variables
char *listwords;
long size = ftell(f);
char *token;
//seek beginning of file
fseek(f, 0, SEEK_SET);
//set the size of array to the file size
listwords = (char*)malloc(size+1);
listwords[size] = '\0';
//reads the data from the file
fread(listwords, size, 1, f);
int i;
for(i=0; (token = strsep(&listwords, " ")); i++)
{//for loop replace certain characters with spaces
if (token != ".")
{
//pointer from the token to the dictionary
wordList->token;
}else if (wordList->token != "!")
{
//pointer from the token to the dictionary
wordList->token;
}else if (token != "?")
{
//pointer from the token to the dictionary
wordList->token;
}else if (token != "\"")
{
//pointer from the token to the dictionary
wordList->token;
}else if (token != ","){
//pointer from the token to the dictionary
wordList->token;
}else
{
//pointer from the token to the dictionary
wordList->token;
}
//increment token to the next word
token++;
}//for loop replace certain characters with spaces
fclose(f);
return;
}//process file
I'm not sure if you would need any more code but I will post any more thats necessary. Thank you in advance.