Comparison of C language strings
#include <stdio.h> #include <the Windows.h> #include < String .h> int main ( void ) { char addr [ 32 ]; the printf ( " What is your Where: " ); Scanf ( " % S " , addr); / * C language may be used to strcmp string comparison, strcmp function accepts two parameters were compared strings and returns a value , such as: strcmp (str1, str2); if str1 is less than str2 (str1 <str2 ), strcmp function returns a value less than 0 (the return value of <0, some compilers -1) if str1 is greater than str2 (str1> str2), strcmp function returns a value of 0 (the return value> is greater than 0, some compilers returns 1) if str1 is equal to str2 (str1 == str2),strcmp function returns 0 * / IF (strcmp (addr, " Hunan " ) == 0 ) { printf ( " What a coincidence, we are fellow oh \ the n-! " ); } the else { printf ( " !% s also my classmate oh \ the n- " , addr) ; } System ( " PAUSE " ); return 0 ; }