char *a = NULL; char *b = NULL; a = foo("Hi there"); b = foo("Goodbye"); printf("From main: %s %s\n", a, b); } char *foo(char *p) { char *q = (char *)malloc(strlen(p)+1); strcpy(q, p); printf("From foo: the string is %s\n", q); return q; } Array q is Heap allocated. Ptr q may be blown away but the string sticks around in the heap The variables and b now point to legitimate strings and should print the actual Values • The string allocated in foo sticks around even after the function returns until it is free’d (where should it be free’d?)