[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: C Programming warning



the func strcasestr not return a pointer...
so, try to use as follows:

if((char*)strcasestr(comment, "</xmp")!=NULL)

but its just a warning, forget it...

On Mon, Jul 14, 2008 at 6:17 AM, Star Liu <minxinjianxin@gmail.com> wrote:
I hope I'm not posting to the wrong place, if so, please remind me :)
I'm making some practice on C programming, so that I can get into the
linux world. Here is a simple code

129     char comment[1025];
130     cgiFormString("comment", comment, 1025);
131     if(strcasestr(comment, "</xmp")!=NULL)
      {
              fprintf(cgiOut, "</xmp is not allowed");
              return;
      }

when i compile, there is a warning:
 gcc -o LeaveMessage LeaveMessage.c cgic.c
LeaveMessage.c: In function 'LeaveMessage':
LeaveMessage.c:131: warning: comparison between pointer and integer

but i found in http://www.gnu.org/software/libc/manual/html_node/Search-Functions.html#Search-Functions
— Function: char * strcasestr (const char *haystack, const char *needle)

So i don't know why i got this warning, what's the correct way to deal with it?

thanks!
--
Regards!
Star
Shanghai, China



--
Regards!
Star
Shanghai, China


Reply to: