Copyright © 2014 by tutorialspoint
#include <stdio.h> int memcmp(const void* cs, const void* ct, int n);
The memcmp function compares the first n bytes from cs and ct and returns a value indicating their relationship as follows:
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
#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; }
It will proiduce following result:
hexchars < hexchars2
Advertisements