strcmp
Previous Topic  Next Topic 

Synopsis:

       hi_same_low=strcmp(str1,str2)


Arguments:

       str1 - The first string to compare

       str2 - The second string to compare

       

Description:  This function carries out an alphabetical comparison between str1 and str2 and will return the following values based upon the result of the comparison:


If str1 > str2 the function will return 1

If str1 = str2 the function will return 0

If str1 < str2 the function will return -1


For Example:


       str1="ABC";

       str2="BBC"

       // This will return 1

       hi_same_low=strcmp(str,str2);


       str1="BBC"

       str2="BBC"

       // This will return 0

       hi_same_low=strcmp(str,str2);


       str1="BBC"

       str2="ABC";

       // This will return -1

       hi_same_low=strcmp(str,str2);


       // Note that because the comparison is done alphabetically then str1 < str2 in the following

       str1="01999";

       str2="1";

       // This will return -1

       hi_same_low=strcmp(str,str2);


Returns:  Returns 1, 0 or -1 depending on whether str1 > str2, str1 = str2 or str1 < str2.