Thread: Please explain strnstr

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    10

    Question Please explain strnstr

    Does anyone know what the string function strnstr does (not strstr), or if it even exists? I can't find anything about it on the Web or in print. I was told (by another programmer) to use it for a program that compares two strings (case insensitive -- which is where the strnstr is suppose to come in handy-- supposedly?). However, this programmer did not explain what strnstr does exactly! A basic definition would be nice to know and a code sample would be great!

    Thanx Folks!

  2. #2
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    I'm sure that someone has written such a function with that name, however, it is not part of the c standard library. I even double checked by searching the includes of all my compilers and found nothing. But you can always make your own.

  3. #3
    Registered User
    Join Date
    Oct 2002
    Posts
    46
    Goggle gave me this...
    http://docs.freebsd.org/mail/archive...bsd-audit.html

    Not a regular libc function yet.

  4. #4
    Registered User
    Join Date
    Aug 2002
    Posts
    30
    Hi,

    Yes this func is not in the standard lib, and is not available in Borland's package either.

    However, if you want to do a case-insensitive compare, you can always use several other funcs, including stricmp(), strcmpi(), strnicmp (Borland) or strcasecmp (GNU).

    If you would like to compare other data types (not char* or const char*) then, memicmp() is for you.

    All these functions (except memicmp) have a ws** version which is useful if you need wide char support.

    Hope this helps!
    Best Regards,

    Bill

  5. #5
    Registered User
    Join Date
    Oct 2002
    Posts
    10
    I found this site on strnstr (finally).

    http://www-es.fernuni-hagen.de/cgi-b...rstr&section=3

    Thanks for all your help, C ya!:

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. One Easy" C " Question. Please Solve and Explain.
    By RahulDhanpat in forum C Programming
    Replies: 18
    Last Post: 03-24-2008, 01:39 PM
  2. Please Explain me few terms that i have listed in here.
    By chottachatri in forum C++ Programming
    Replies: 3
    Last Post: 02-26-2008, 08:20 AM
  3. Please explain?
    By neo_phyte in forum C Programming
    Replies: 3
    Last Post: 08-25-2006, 05:23 AM
  4. Pls explain how this program works...
    By Unregistered in forum C Programming
    Replies: 9
    Last Post: 01-05-2002, 09:53 AM
  5. Can someone explain "extern" to me?
    By valar_king in forum C++ Programming
    Replies: 3
    Last Post: 09-16-2001, 12:22 AM