Click here to Skip to main content
15,903,385 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: pointer Pin
jith - iii25-May-06 19:22
jith - iii25-May-06 19:22 
GeneralRe: pointer Pin
S. Senthil Kumar25-May-06 19:52
S. Senthil Kumar25-May-06 19:52 
GeneralRe: pointer [modified] Pin
jith - iii25-May-06 21:09
jith - iii25-May-06 21:09 
GeneralRe: pointer Pin
S. Senthil Kumar25-May-06 22:59
S. Senthil Kumar25-May-06 22:59 
GeneralRe: pointer [modified] Pin
jith - iii25-May-06 23:31
jith - iii25-May-06 23:31 
GeneralRe: pointer [modified] Pin
S. Senthil Kumar26-May-06 14:27
S. Senthil Kumar26-May-06 14:27 
GeneralRe: pointer [modified] Pin
jith - iii26-May-06 19:02
jith - iii26-May-06 19:02 
GeneralRe: pointer [modified] Pin
S. Senthil Kumar26-May-06 20:42
S. Senthil Kumar26-May-06 20:42 
jithAtran - ii wrote:
That means i has been given an address space in the memory(1000/1001).
Now we are trying to store an address say

like
______________
__00__|___7D__ where 007D is the address of a
1000 1001 float variable.

Now here is my doubt.How compiler knows this assignment is wrong.


Well, you're not doing
int *p = 0x007D;

are you? You are attempting to assign the address of a float variable to an integer pointer, so that's why the assignment is wrong.

The compiler knows this because, when it compiles code, it keeps track of the type of all variables, using something called a symbol table[^]. When it's time to generate code, it sees this line
float k = 10.0;
int *p = &k;

it realizes that p is a pointer to int and k is a float and therefore generates an error. If you want to know how it gets that information from the source code, google for "Parsing and Syntax Analysis", which is a pretty huge topic in itself.

Again, the compiler doesn't know addresses 1001/1002 are for pointing to integers, rather, it only knows that p is a pointer to an integer. The absolute address of the pointer itself is determined at runtime.

Regards
Senthil
_____________________________
My Blog | My Articles | My Flickr | WinMacro
GeneralRe: pointer [modified] Pin
jith - iii26-May-06 22:30
jith - iii26-May-06 22:30 
GeneralRe: pointer [modified] Pin
Stephen Hewitt26-May-06 18:05
Stephen Hewitt26-May-06 18:05 
GeneralRe: pointer [modified] Pin
S. Senthil Kumar26-May-06 20:35
S. Senthil Kumar26-May-06 20:35 
AnswerRe: pointer [modified] Pin
Member 303984325-May-06 19:29
Member 303984325-May-06 19:29 
AnswerRe: pointer [modified] Pin
Saday Sarkar25-May-06 19:51
Saday Sarkar25-May-06 19:51 
GeneralRe: pointer [modified] Pin
jith - iii25-May-06 21:11
jith - iii25-May-06 21:11 
GeneralRe: pointer [modified] Pin
Stephen Hewitt26-May-06 18:25
Stephen Hewitt26-May-06 18:25 
GeneralRe: pointer [modified] Pin
jith - iii26-May-06 19:06
jith - iii26-May-06 19:06 
QuestionLinux's gettimeofday() equivalent for windows Pin
useme12325-May-06 18:41
useme12325-May-06 18:41 
AnswerRe: Linux's gettimeofday() equivalent for windows Pin
Ganesh_T25-May-06 18:51
Ganesh_T25-May-06 18:51 
GeneralRe: Linux's gettimeofday() equivalent for windows Pin
ThatsAlok25-May-06 22:18
ThatsAlok25-May-06 22:18 
AnswerRe: Linux's gettimeofday() equivalent for windows Pin
Nibu babu thomas25-May-06 18:53
Nibu babu thomas25-May-06 18:53 
AnswerRe: Linux's gettimeofday() equivalent for windows Pin
Ryan Binns25-May-06 18:57
Ryan Binns25-May-06 18:57 
QuestionAbout threading Pin
Aqueel25-May-06 18:30
Aqueel25-May-06 18:30 
AnswerRe: About threading Pin
Nibu babu thomas25-May-06 18:38
Nibu babu thomas25-May-06 18:38 
AnswerRe: About threading Pin
_AnsHUMAN_ 25-May-06 18:43
_AnsHUMAN_ 25-May-06 18:43 
AnswerRe: About threading Pin
ThatsAlok25-May-06 22:19
ThatsAlok25-May-06 22:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.