// Capitalizes a copy of a string using strcpy while checking for errors #include #include #include #include int main(void) { // Get a string char *s = get_string("s: "); if (!s) { return 1; } // Allocate memory for another string char *t = malloc((strlen(s) + 1) * sizeof(char)); if (!t) { return 1; } // Copy string into memory strcpy(t, s); // Capitalize first letter in copy if (strlen(t) > 0) { t[0] = toupper(t[0]); } // Print strings printf("s: %s\n", s); printf("t: %s\n", t); // Free memory free(t); return 0; }