/* File: examples.c More examples of string functions. */ #include #include #include "genlib.h" #include "simpio.h" #include "strlib.h" main() { string str1, str2, str3 ; int n, m ; double x ; str1 = "Conjunction junction what's your function?" ; str2 = "3.14159" ; str3 = "100123" ; n = FindChar('w', str1, 0) ; printf("n = %d\n", n) ; m = FindString("unction", str1, n) ; printf("m = %d\n", m) ; x = StringToReal(str2) ; n = StringToInteger(str3) ; printf("x = %g, n = %d\n", x, n) ; x = 2 * x ; n = n + 1 ; str2 = RealToString(x) ; str3 = IntegerToString(n) ; printf("str2 = %s, str3 = %s\n", str2, str3) ; str2 = "Begin" ; str3 = "End" ; if ( StringCompare(str2, str3) < 0) { printf("%s comes before %s\n", str2, str3) ; } else { printf("%s comes after %s\n", str2, str3) ; } }