Reputation: 11
I am doing a word search program and keep getting the same error that doesn't give me much information about whats wrong. Specifically it says this...
wordSearch.c:38:32: error: expected
expression
returnWord = (char *) strstr(char const *sentence, char const *phrase);
^
^
what could this be?
Upvotes: 1
Views: 1093
Reputation: 311
Based on the pictures, it looks as if something is wrong with strstr
. This makes sense because of the way you are passing arguments. strstr
expects two const char *
arguments, however you have casted them incorrectly. Additionally, since strstr
already returns a char *
there is no need to cast that. Thus, line 38 should be returnword = strstr((const char *) sentence, (const char *) phrase);
Upvotes: 0
Reputation: 134366
returnWord = char *strstr(const char *sentence, const char *phrase);
is not how you call a function. Get rid of the return type, simply use
returnWord = strstr(sentence, phrase);
assuming sentence
and phrase
are variables are defined and having proper values.
Upvotes: 3