• C

Why warning message in using strcasestr() ?

Hello group,

In following code, I'm getting warning messages as

warning: implicit declaration of function `strcasestr'
warning: assignment makes pointer from integer without a cast
warning: assignment makes pointer from integer without a cast

for using strcasestr(). As far I know the inputs must be const char* and its ouput must get into a char*.

Any idea where I went wrong?

Thanks.



const char* b_tag = "<title>";
       const char* e_tag = "</title>";
       char* p_start = NULL;
       char* p_end   = NULL;
 
       p_start = strcasestr(buf, b_tag);  //buf contains an html body
       p_end   = strcasestr(buf, e_tag);

Open in new window

akohanAsked:
Who is Participating?
 
sunnycoderConnect With a Mentor Commented:
#define _GNU_SOURCE
#include <string.h>
0
 
sunnycoderCommented:
#define <string.h>
0
 
sunnycoderCommented:
oops #include and not #define
0
 
akohanAuthor Commented:

It was there when I got this warning.
0
 
lhl60Commented:
you must be missing an include file, are your include paths ok?

"warning: implicit declaration of function `strcasestr'"

Because strcasstr is not defined any where,
the compiler will assume the default declaration of "unknown" functions

int strcasestr();

that explains:
warning: assignment makes pointer from integer without a cast
warning: assignment makes pointer from integer without a cast
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.