my structure is:
-
char *sent[5],word[5];
-
if(strcmp(*sent[5],word[5])==0)
-
printf("the word found.");
-
strcmp syntax is:
strcmp(const char *s1,const char *s2) and your type is same as **sent which is same as sent[][],so
instead use it like:
strcmp(sent,word)
Well, not exactly.
**sent is not "the same as"
sent[][].
char *sent[5] is an array of 5 char pointers.
char word[5] is an array of 5 chars.
However, the prototype Savage gave is correct.
If you are using
word to store a c-string and you are using
sent to store an array of 5 c-strings then you would have to change it so that
strcmp will receive a
char const * or a
char * (which the language will automatically convert to const). So if you compare the 0th c-string pointed at by sent to the c-string stored in word, you would use
strcmp(sent[0], word).
The array will auto degrade to a pointer when used like this.
NOTE: You have not assigned the 5 pointers in
sent, they are pointing at random memory locations. Also,
word is not initialised either so its values are also indeterminate.