[ Date Index ][
Thread Index ]
[ <= Previous by date /
thread ]
[ Next by date /
thread => ]
Must be in C, not C++
Basically, with two strings, a calculation for the distance between the two strings so can determine the closest match.
#include <stdio.h> #include <string.h>
char str1[3] = "B0"; char str2[3] = "A9"; char str3[3] = "B1"; char str4[4] = "B0";
void main()
{result = strcmp(str1,str2);
if (result == 0)
printf("strings are identical\n");
else if(result < 0)
printf("string1 is less than string 2\n");
else
printf("string1 is greater than string 2\n");result = strcmp(str2,str1);
if (result == 0)
printf("strings are identical\n");
else if(result < 0)
printf("string1 is less than string 2\n");
else
printf("string1 is greater than string 2\n");result = strcmp(str1,str4);
if (result == 0)
printf("strings are identical\n");
else if(result < 0)
printf("string1 is less than string 2\n");
else
printf("string1 is greater than string 2\n");
}-- The Mailing List for the Devon & Cornwall LUG Mail majordomo@xxxxxxxxxxxx with "unsubscribe list" in the message body to unsubscribe.