/* This program uses code from "Algorithms in C, Third Edition," * by Robert Sedgewick, Addison-Wesley, 1998. */ #ifndef BASIC_STRINGS_H #define BASIC_STRINGS_H /* return the length of string s, i.e., the number of * characters up to and not including the first occurrence of * the NULL character. */ int strlen1(char * s); /* copy the contents of source to the target string. */ void strcpy1(char * target, char * source); /* ASCII-based comparison of the two strings. * Return values: * 0, if the two srings have the same contents. * less than 0, if the ASCII code of s1 is less than the ASCII code * of s2 at the first position where s1 and s2 differ. * greater than 0, if the ASCII code of s1 is greater than the ASCII code * of s2 at the first position where s1 and s2 differ. */ int strcmp1_unoptimized(char * s1, char * s2); /* ASCII-based comparison of the two strings. * Return values: * 0, if the two srings have the same contents. * less than 0, if the ASCII code of s1 is less than the ASCII code * of s2 at the first position where s1 and s2 differ. * greater than 0, if the ASCII code of s1 is greater than the ASCII code * of s2 at the first position where s1 and s2 differ. */ int strcmp1(char * s1, char * s2); /* ASCII-based comparison of the first N letters of two strings. * Return values: * 0, if the two srings have the same contents. * less than 0, if the ASCII code of s1 is less than the ASCII code * of s2 at the first position where s1 and s2 differ. * greater than 0, if the ASCII code of s1 is greater than the ASCII code * of s2 at the first position where s1 and s2 differ. */ int strncmp1(char * s1, char * s2, int N); char * strcat1(char * a, char * b); #endif // BASIC_STRINGS_H