int *mInt = 5; // Error
char *mString = "hello!"; //Works
but..why? is it because the mString is an array of chars?
i dont get it lol..what is the rule here?
Printable View
int *mInt = 5; // Error
char *mString = "hello!"; //Works
but..why? is it because the mString is an array of chars?
i dont get it lol..what is the rule here?
int* mInt is a pointer to an int, not an int. So you assign 5 to it, whioch means it is pointing at an int in memory at location 0x00000005, which is illegal.
char* mString is a pointer to a char, not a char. However, when you assign a string to it like that, that string already has a memory address that is legal.
Z.
yes thats what i though when i started reading ur post lol