C memcmp function

« Previous

Synopsis:

Example

#include <stdio.h>
int memcmp(const void* cs, const void* ct, int n); 

Description:

The memcmp function compares the first n bytes from cs and ct and returns a value indicating their relationship as follows:

Return Value

  • if Return value if < 0 then it indicates cs less than ct

  • if Return value if > 0 then it indicates ct is less than cs

  • if Return value if = 0 then it indicates cs is equal to ct

Example

Example

#include <stdio.h>
int main() {
  char hexchars [] = "0123456789ABCDEF";
  char hexchars2 [] = "0123456789abcdef";
  char i;
  i = memcmp (hexchars, hexchars2, 16);
  if (i < 0)
    printf ("hexchars < hexchars2\n");
  else if (i > 0)
    printf ("hexchars >  hexchars2\n");
  else
    printf ("hexchars == hexchars2\n");
  return 0;
}

Output Will Be :

Output

hexchars < hexchars2


« Previous
Have Any Suggestion? We Are Waiting To Hear from YOU!

Your Query was successfully sent!