|
-
Feb 19th, 2003, 10:58 AM
#1
Thread Starter
yay gay
pointers question
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?
\m/  \m/
-
Feb 19th, 2003, 12:27 PM
#2
Frenzied Member
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.
-
Feb 19th, 2003, 02:48 PM
#3
Thread Starter
yay gay
yes thats what i though when i started reading ur post lol
\m/  \m/
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|