Computing.Net > Forums > Linux > what will !strstr(abcdefgh,efg

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

what will !strstr(abcdefgh,efg

Reply to Message Icon

Name: surbhigarg
Date: March 16, 2006 at 01:18:17 Pacific
OS: linux
CPU/Ram: p-4,256 mb
Product: ibm
Comment:

what will !strstr("abcdefgh","efg") return?




Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: March 16, 2006 at 11:31:18 Pacific
Reply:

The strstr searchs the first arg for the first occurrence of the 2nd argument. If it finds it it returns a character pointer to the first occurrence. It it doesn't find it, it returns a null pointer.

Since strstr("abcdefgh", "efg") is true, placeing ! in front makes it false.

All the not, the ! character, does is allow you to substitute this code:

char *found;

/*remember that NULL is false */
found=strstr("abcdefgh","hhh");
if(found == NULL)
printf("efg is not there\n");

with this:

/* its true that hhh is not there */
if(!strstr("abcdefgh","hhh"))
printf("efg is not there\n");



0
Reply to Message Icon

Related Posts

See More


Kernel Install Question Linux user and password r...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Linux Forum Home


Sponsored links

Ads by Google


Results for: what will !strstr(abcdefgh,efg

what will a graphics card do for X11? www.computing.net/answers/linux/what-will-a-graphics-card-do-for-x11/6704.html

What will Win4Lin 5.1 run with? www.computing.net/answers/linux/what-will-win4lin-51-run-with/26026.html

What Linux? www.computing.net/answers/linux/what-linux/17598.html