/**************************************************************************** * copy1.c * * David J. Malan * malan@harvard.edu * * Tries and fails to copy two strings. * * Demonstrates strings as pointers to arrays. ***************************************************************************/ #include #include #include #include #include int main(void) { // get line of text printf("Say something: "); string s = GetString(); if (s == NULL) return 1; // try (and fail) to copy string string t = s; // change "copy" printf("Capitalizing copy...\n"); if (strlen(t) > 0) t[0] = toupper(t[0]); // print original and "copy" printf("Original: %s\n", s); printf("Copy: %s\n", t); return 0; }