"Nelu" <tandauioan@gmail.com> writes:[color=blue]
>
bijayadipti@gmail.com wrote:[color=green]
>> Hi,
>>
>> I have a C program. I have compiled it uisng gcc and also avr-gcc. Now
>> after compiling, I want to know the addresses of the two variables in
>> my program. Is there any options that I can use to find that out? Is
>> there any way at all to find that out? Someone told that it was
>> possible but I am not able to find out.[/color]
>
> If you want to display the adress of a variable from the program you
> can use %p for printf format, e.g. printf("Address var1=%p,
> var2=%p",&v1, &v2); (where v1 and v2 are your variables).
> If you want to find the address of the variables in the compiled
> program you may have a problem. Consider the case of a recursive
> function. The local variables are going to be created at different
> addresses with each recursive call.[/color]
The "%p" format requires an argument of type void*. The printf call
above should be:
printf("Address var1=%p, var2=%p", (void*)&v1, (void*)&v2);
--
Keith Thompson (The_Other_Keith)
kst-u@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.