Re: How to test whether strstr() returns a null pointer or not?
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: Sat, 04 Jun 2005 18:08:25 GMT
Paul Mesken <usurper@xxxxxxxxxx> writes:
> On Sat, 04 Jun 2005 14:09:19 GMT, John Smith <jsmith@xxxxxxxxxxx>
> wrote:
>>SM Ryan wrote:
>>> John Smith <jsmith@xxxxxxxxxxx> wrote:
>>> > How to test whether strstr() returns a null pointer or not? Do I
>>> > use something like the following?
>>> >
>>> > if(NULL != strstr(str1,str2))
>>>
>>> if (strstr(str1,str2))
>>>
>>> always works for me.
>>>
>>
>>Thanks. That works.
>
> That's really odd.
[...]
> What exactly didn't work in your program? I believe the Standard only
> requires the macro NULL to be defined in <stddef.h>. Perhaps if you
> include <stddef.h> in your program it will work.
If the OP didn't #include one of the headers that defines NULL, he
should have gotten a compilation error. Since all he told us was that
"That does not seem to work", I'm assuming it compiled but didn't
behave the way he expected. (Note to everyone posting questions: you
need to tell us *how* it doesn't work.)
If NULL has been redefined somewhere, he needs to track it down and
fix it. Redefining NULL is a very bad idea.
--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
.
- References:
- How to test whether strstr() returns a null pointer or not?
- From: John Smith
- Re: How to test whether strstr() returns a null pointer or not?
- From: SM Ryan
- Re: How to test whether strstr() returns a null pointer or not?
- From: John Smith
- Re: How to test whether strstr() returns a null pointer or not?
- From: Paul Mesken
- How to test whether strstr() returns a null pointer or not?
- Prev by Date: Re: why debug step by step, it s ok
- Next by Date: Re: How to test whether strstr() returns a null pointer or not?
- Previous by thread: Re: How to test whether strstr() returns a null pointer or not?
- Next by thread: Re: How to test whether strstr() returns a null pointer or not?
- Index(es):
Relevant Pages
|