J
jeffmax
Can anyone explain why the following code works?
#include <iostream>
int main ()
{
char (*p)[];
p = (char(*)[]) new (char[3]);
(*p)[0] = 'c';
cout << (*p) << endl;
}
The above code will print out 'c'. Why is it that the line
(*p)[0]='c' does not cause a segfault? Isn't it the equivalent of
*(*p).
#include <iostream>
int main ()
{
char (*p)[];
p = (char(*)[]) new (char[3]);
(*p)[0] = 'c';
cout << (*p) << endl;
}
The above code will print out 'c'. Why is it that the line
(*p)[0]='c' does not cause a segfault? Isn't it the equivalent of
*(*p).