Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   search qustion (http://www.go4expert.com/forums/search-qustion-t18344/)

hoda 4Jul2009 02:44

search qustion
 
in my program,i give each user an ID code but maybe user forget ID, then i want to search his or her name in a way that if i print part of the user's name ,program shows me all of names which have that part then i choose between them.
how can i do that??

xpi0t0s 4Jul2009 03:39

Re: search qustion
 
strstr is a useful function for finding a substring.

hoda 4Jul2009 21:37

Re: search qustion
 
Quote:

Originally Posted by xpi0t0s (Post 51314)
strstr is a useful function for finding a substring.

but with strstr we can find the exact name.i want to type part of the name then compiler shows me all of the names with this part then i can choose.

xpi0t0s 5Jul2009 04:36

Re: search qustion
 
No, you're thinking of strcmp. strstr is a function that finds substrings of a string, so if you give it the parameters "look it up in the docs bozo" and "docs" then it will give you a pointer to "docs", thus confirming that "docs" is indeed in the string.


All times are GMT +5.5. The time now is 12:56.