Here is what I have to do:
Add a clearList function that will traverse the array of strings and free the malloced strings as it goes. Set each element to NULL also. Don't forget to pass a pointer to the numWords counter .... yada yada
Here is what I have: // wordType is a struct we are using
void clearlist(wordType words[], int * numWords)
{
int k;
for (k = 0; k < *numWords; k++)
{
free(words[*numWords].word); // this is to free the malloced strings
words[*numWords] = NULL; // this is where I get my error : Line 114
}
*numWords = 0;
}
This is my error:
[mgimbl@localhost assignment4]$ make
gcc -c assign4.c
assign4.c: In function `clearlist':
assign4.c:114: error: incompatible types in assignment
make: *** [assign4.o] Error 1
Any suggestions?
Add a clearList function that will traverse the array of strings and free the malloced strings as it goes. Set each element to NULL also. Don't forget to pass a pointer to the numWords counter .... yada yada
Here is what I have: // wordType is a struct we are using
void clearlist(wordType words[], int * numWords)
{
int k;
for (k = 0; k < *numWords; k++)
{
free(words[*numWords].word); // this is to free the malloced strings
words[*numWords] = NULL; // this is where I get my error : Line 114
}
*numWords = 0;
}
This is my error:
[mgimbl@localhost assignment4]$ make
gcc -c assign4.c
assign4.c: In function `clearlist':
assign4.c:114: error: incompatible types in assignment
make: *** [assign4.o] Error 1
Any suggestions?
