C / string.h / strcmp
memchr, memcmp, memcpy, memmove, memset, strcat, strchr, » strcmp, strcoll, strcpy, strcspn, strerror, strlen, strncat, strncmp, strncpy, strpbrk, strrchr, strspn, strstr, strtok, strxfrm,
Funcion: strcmp()
Sintaxis:
Descripcion: Compara la cadena apuntada por s1 con la cadena apuntada por s2.
Ejemplo:
Sintaxis:
int strcmp(const char *s1, const char *s2);
Descripcion: Compara la cadena apuntada por s1 con la cadena apuntada por s2.
Ejemplo:
#include <stdio.h> #include <string.h> int main() { char s1[5] = "Abeja"; char s2[5] = "abeja"; int i; printf( "s1=%s\t", s1 ); printf( "s2=%s\n", s2 ); i = strcmp( s1, s2 ); printf( "s1 es " ); if( i < 0 ) printf( "menor que" ); else if( i > 0 ) printf( "mayor que" ); else printf( "igual a" ); printf( " s2\n" ); return 0; }