Name

bcmp - compares byte sequences

Library

libc.lib

Synopsis

  #include <strings.h>
  int bcmp (const void *b1, const void *b2, size_t len);

Return values

bcmp function returns 0 if the byte sequences are equal, otherwise a non-zero result is returned.


Detailed description

The bcmp function compares byte string b1 against byte string b2, returning zero if they are identical, non-zero otherwise. Both strings are assumed to be len bytes long. Zero-length strings are always identical.

The strings may overlap.


Examples

#include <string.h>
#include <stdio.h>
int main()
{
   int ret = 0;
   ret = bcmp("a","a",1);               
   printf("bcmp(\"a\",\"a\",1) is %d",ret);
   ret = bcmp("abcd","abce",4); 
   printf("\nbcmp(\"abcd\",\"abce\",1) is %d",ret);
   ret = bcmp("abc","xyz",0);
   printf("\nbcmp(\"abc\",\"xyz\",0) is %d",ret);
   return 0;
}

         

Output

bcmp("a","a",1) is 0
bcmp("abcd","abce",1) is -1
bcmp("abc","xyz",0) is 0

         

See also

memcmp, strcasecmp, strcmp, strcoll, strxfrm

Feedback

For additional information or queries on this page send feedback

© 2005-2007 Nokia

Top