bcmp(3C) DG/UX 4.30 bcmp(3C)
NAME
bcmp - compare two areas of memory
SYNOPSIS
int bcmp(), result, length;
char *ptr1, *ptr2;
result = bcmp(ptr1, ptr2, length);
ptr1 A pointer to the first area.
ptr2 A pointer to the second area.
length The number of bytes to compare.
DESCRIPTION
The bcmp function compares two areas of memory, byte by
byte, as unsigned values. It compares the number of bytes
you specify with length; this function comes from the
University of California Berkeley UNIX (BSD) system. Unlike
the memcmp function, the bcmp function tests only for
equality. This function does not indicate whether the first
area is greater or less than the second area.
RETURNS
The bcmp function returns 0 if the areas are equal.
Otherwise, it returns a nonzero value. However, if length
is negative, the function bcmp returns 0.
EXAMPLE
The following program compares an input string to the
username mike.
/* Program test for the bcmp() function */
#include <stdio.h>
int bcmp();
char buf[80];
main() {
printf("Type in a name: ");
if (fgets(buf, sizeof(buf), stdin)) {
if (!bcmp(buf, "mike\n", 5))
printf("You typed mike!\n");
else
printf("You did not type mike.\n");
}
return 0;
}
SEE ALSO
memcmp(3C).
Licensed material--property of copyright holder(s) Page 1