Dynamic Memory Allocation

Two new commands to use in concert:

Example: Copying a String Instead of Its Pointer

string s = get_string();
string t = malloc(strlen(s) + 1); // (The extra byte is for the \0 char)
if (t == NULL)
    return 1; // (quit if memalloc fails)
/*
for (int i = 0, n = strlen(s) + 1; i < n; i++) {
    t[i] = s[i];
}
*/
strcpy(t, s); // Alternative to the for loop using stdlib.h
t[0] = toupper(t[0]);
printf("%s\n", s);
printf("%s\n", t);

free(t);