#include #include // compare this to the foo function of example6.cpp. // Here, the argument is a single pointer, not a double pointer. void foo(char * b) { b = (char *) malloc(sizeof(char) * 6); b[0] = 'h'; b[1] = 'e'; b[2] = 'l'; b[3] = 'l'; b[4] = 'o'; b[5] = 0; } int main() { char * a = "john"; printf("before calling foo:\n"); printf("a = %s\n\n", a); foo(a); // note that, in contrast to example6.cpp, the value of a // is NOT different after calling the foo function printf("after calling foo:\n"); printf("a = %s\n", a); }