As far as I know the below code should not work. Yet, somehow this is OK on my compiler. Please could someone explain.
int main()
{
char *string;
string = "Goo";
}
As far as I know the below code should not work. Yet, somehow this is OK on my compiler. Please could someone explain.
int main()
{
char *string;
string = "Goo";
}
I'm afraid, your information is wrong.
is perfectly valid. This is basically,
char
pointerstring
."Goo"
intostring
.However, instead of being a
char
pointer, ifstring
would have been an array, then this would not have been possible as array's cannot be assigned (except definition time though brace enclosed list).