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