evaluate NULL to a pointer which a CONST pointer points to

evaluate NULL to a pointer which a CONST pointer points to

Post by G » Tue, 09 Jan 2007 12:57:39


Hi~
you guys.
I come across the code below:
/////////////////////////////////////////////////////////
#include <stdio.h>
void foo(const char **pp)
{
*pp=NULL;
//it works too
//*pp="Hello world!";
}

int main()
{
const char *p="hello";
foo(&p);
printf("%s",p);
return 0;
}
//////////////////////////////////////////////////////////
It was compiled successed without no warn or error.

Why can *pp change , though " const char **pp " meant it couldn't ?

Thank you ! :-)