I am trying to debug this code. It is not doing the expected.
#define HELLO_WORLD_STRING “hello world”
void f(char* p)
{
p = (char *)malloc(strlen(HELLO_WORLD_STRING)+1);
ASSERT(p != NULL);
strcpy(p, HELLO_WORLD_STRING);
}
void main()
{
char * p;
f(p);
printf(“%s\n”, p);
free(p);
}
Why is the code in error?