如何测试strstr()是否返回空指针? [英] How to test whether strstr() returns a null pointer or not?
问题描述
如何测试strstr()是否返回空指针?我是否使用以下内容获得
?
if(NULL!= strstr(str1,str2))
这似乎不起作用。
John Smith< js **** @ company.com>写道:
#如何测试strstr()是否返回空指针?我是否使用以下内容来支付
#
#
#if(NULL!= strstr(str1,str2))
if(strstr(str1,str2))
总是对我有用。
#
#这似乎不起作用。
#
#
-
SM Ryan http://www.rawbw.com/~wyrmwif/
我今天甚至不应该在这里。
2005年6月4日星期六02:56:05 GMT ,John Smith< js **** @ company.com>
写道:
如何测试strstr()是否返回空指针?我是否使用类似下面的内容?
if(NULL!= strstr(str1,str2))
这似乎不起作用。
不起作用怎么样?告诉我们您的期望以及实际发生的事情
。提供一些可编译的代码来演示这种行为。
<<删除电子邮件的del>>
< blockquote> John Smith在04/06/05写道:
如何测试strstr()是否返回空指针?我是否使用类似下面的内容?
if(NULL!= strstr(str1,str2))
这似乎不起作用。
举一个完整的例子。我怀疑str1和
str2指向的字符串不是你期望的字符串(例如,对于
的例子来说,额外的尾随''\ n''。 。)。
-
Emmanuel
C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
C库: http://www.dinkumware .com / refxc.html
今天世界上有10种类型的人;
了解二元的人,以及那些不要。
How to test whether strstr() returns a null pointer or not? Do I
use something like the following?
if(NULL != strstr(str1,str2))
That does not seem to work.
John Smith <js****@company.com> 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.
#
# That does not seem to work.
#
#
--
SM Ryan http://www.rawbw.com/~wyrmwif/
I''m not even supposed to be here today.
On Sat, 04 Jun 2005 02:56:05 GMT, John Smith <js****@company.com>
wrote:
How to test whether strstr() returns a null pointer or not? Do I
use something like the following?
if(NULL != strstr(str1,str2))
That does not seem to work.
Does not work how? Tell us what you expect and what actually
happens. Provide some compilable code that demonstrates this
behavior.
<<Remove the del for email>>
John Smith wrote on 04/06/05 :How to test whether strstr() returns a null pointer or not? Do I
use something like the following?
if(NULL != strstr(str1,str2))
That does not seem to work.
Give a complete example. I suspect that the strings pointed by str1 and
str2 are not the ones you are expecting (say, a extra trailing ''\n'' for
example...).
--
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
The C-library: http://www.dinkumware.com/refxc.html
"There are 10 types of people in the world today;
those that understand binary, and those that dont."
这篇关于如何测试strstr()是否返回空指针?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!