View Single Post
Old Jun 28th, 2007, 12:05 AM   #7
Darkhack
Hobbyist Programmer
 
Darkhack's Avatar
 
Join Date: Dec 2005
Location: Kansas City
Posts: 102
Rep Power: 3 Darkhack is on a distinguished road
Send a message via AIM to Darkhack
Quote:
Originally Posted by Fall Back Son View Post
In any case, assigning integer expressions to pointer variables is an illegal operation.
Ahh okay. My whole reason for asking this was trying to understand pointers. I'm not using it for a real application. Why is it okay to do the same thing with a character pointer but not an integer? I understand that in this example the string is an array of characters and that "s" by itself is a pointer to where the string starts, but why wouldn't "i" be the memory address of where 10 was created?

char *s = "Hello World!";  // legal
int *i = 10; // illegal, but why?
Darkhack is offline   Reply With Quote