Where is the defination of memcmp?

This is a discussion on Where is the defination of memcmp? within the C Programming forums, part of the General Programming Boards category; Dear all, What is the standard file to use memcmp? i am getting repeatedly " memcmp is undefined ."...

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    83

    Where is the defination of memcmp?

    Dear all,
    What is the standard file to use memcmp? i am getting repeatedly "memcmp is undefined."

  2. #2
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,239
    Quote Originally Posted by shwetha_siddu View Post
    Dear all,
    What is the standard file to use memcmp? i am getting repeatedly "memcmp is undefined."
    string.h
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  3. #3
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    I've always wondered why they put it in string.h instead of something like memory.h.
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by cpjust View Post
    I've always wondered why they put it in string.h instead of something like memory.h.
    Because I suspect it was part of the same (small set of) source file(s) - probably written in assembler to make the best performance. And since the group of memcpy, strcpy, strcat and group of memcmp, strcmp are often quite alike, it's possible to re-use some of the code in one from the other,e.g. use strlen() + memcpy() to do strcpy(), strcat() - or write some code that is shared by both.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Access Violation using memcmp?
    By someprogr in forum C Programming
    Replies: 3
    Last Post: 12-31-2007, 12:45 AM
  2. error LNK2005: _DllMain@12 already defined in SPLibrSync.obj
    By dattaforit in forum C++ Programming
    Replies: 7
    Last Post: 11-23-2006, 06:32 AM
  3. Question about using memcmp ()
    By Vortex in forum C++ Programming
    Replies: 5
    Last Post: 06-03-2006, 03:44 PM
  4. Strings are V important...
    By NANO in forum C++ Programming
    Replies: 15
    Last Post: 04-14-2002, 11:57 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21