Updated: April 19, 2023 |
Compare two strings
#include <string.h> int strcmp( const char* s1, const char* s2 );
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The strcmp() function compares the string pointed to by s1 to the string pointed to by s2.
#include <stdio.h> #include <string.h> #include <stdlib.h> int main( void ) { printf( "%d\n", strcmp( "abcdef", "abcdef" ) ); printf( "%d\n", strcmp( "abcdef", "abc" ) ); printf( "%d\n", strcmp( "abc", "abcdef" ) ); printf( "%d\n", strcmp( "abcdef", "mnopqr" ) ); printf( "%d\n", strcmp( "mnopqr", "abcdef" ) ); return EXIT_SUCCESS; }
produces the output:
0 1 -1 -1 1
Processes that register ISRs shouldn't use the NEON versions.
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | Read the Caveats |
Signal handler | Yes |
Thread | Yes |
Implementations of strcmp() that are optimized using SIMD instructions aren't safe to use in an interrupt handler. These include the NEON implementations on ARMv7 and AArch64.