#include #include #include "basic_strings.h" main(int argc, char ** argv) { char * s1 = "Monday"; char * s2 = malloc(1000 * sizeof(char)); strcpy1(s2, "hello"); printf("s1: %s\n", s1); printf("s2: %s\n", s2); printf("s1 length = %d\n", strlen1(s1)); printf("s2 length = %d\n", strlen1(s2)); printf("strcmp_unoptimized(s1, s2) = %d\n", strcmp1_unoptimized(s1, s2)); printf("strcmp(s1, s2) = %d\n", strcmp1(s1, s2)); printf("strncmp(sun, sunday, 3) = %d\n", strncmp1("sun", "sunday", 3)); printf("strncmp(sun, sunday, 5) = %d\n", strncmp1("sun", "sunday", 5)); printf("strncmp(sunday, sun, 5) = %d\n", strncmp1("sunday", "sun", 5)); printf("strncmp(sunk, sunday, 3) = %d\n", strncmp1("sunk", "sunday", 3)); printf("strncmp(sunk, sunday, 4) = %d\n", strncmp1("sunk", "sunday", 4)); printf("strncmp(sunday, sunk, 3) = %d\n", strncmp1( "sunday", "sunk", 3)); strcat1(s2, " "); strcat1(s2, s1); printf("after strcat operation, s2 = %s\n", s2); // printf("original strncmp(sun, sunday, 3) = %d\n", strncmp("sun", "sunday", 3)); // printf("original strncmp(sun, sunday, 5) = %d\n", strncmp("sun", "sunday", 5)); // printf("original strncmp(sunday, sun, 5) = %d\n", strncmp("sunday", "sun", 5)); // printf("original strncmp(sunk, sunday, 3) = %d\n", strncmp("sunk", "sunday", 3)); // printf("original strncmp(sunk, sunday, 4) = %d\n", strncmp("sunk", "sunday", 4)); // printf("original strncmp(sunday, sunk, 3) = %d\n", strncmp( "sunday", "sunk", 3)); free(s2); return 0; }