Updated: April 19, 2023 |
Compare a given number of characters in two strings
#include <strings.h> int bcmp( const void *s1, const void *s2, size_t n );
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The bcmp() function compares the byte string pointed to by s1 to the string pointed to by s2. The number of bytes to compare is specified by n. NUL characters may be included in the comparison.
#include <stdlib.h> #include <stdio.h> #include <string.h> int main( void ) { if( bcmp( "Hello there", "Hello world", 6 ) ) { printf( "Not equal\n" ); } else { printf( "Equal\n" ); } return EXIT_SUCCESS; }
produces the output:
Equal
Standard Unix; removed from POSIX.1-2008
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | Yes |
Signal handler | Yes |
Thread | Yes |