What address in memory wil be assigned to the following:
float *floatptr;
floatptr = 100;
floatptr = +- 8;
What address in memory wil be assigned to the following:
float *floatptr;
floatptr = 100;
floatptr = +- 8;
Output from compiler:Code:#include <stdio.h> int main(void) { float *floatptr; floatptr = 100; printf("pointer address is %p\n", floatptr); floatptr = +- 8; printf("pointer address is %p\n", floatptr); return(0); }
Output from program when run:Code:Borland C++ 5.5 for Win32 Copyright (c) 1993, 2000 Borland E:\AAPgm\MyProg\C\junk\junk6.c: Warning W8069 E:\AAPgm\MyProg\C\junk\junk6.c 6: Nonportable pointer conversion in function main Warning W8069 E:\AAPgm\MyProg\C\junk\junk6.c 8: Nonportable pointer conversion in function main Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
You don't assign hard coded values to pointer in this manner (with the exception of NULL).Code:E:\AAPgm\MyProg\C\junk>junk6 pointer address is 00000064 pointer address is FFFFFFF8
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
> You don't assign hard coded values to pointer in this manner (with the exception of NULL).
Actually, that's not absolute. Obviously, there is a time and place to actually assign hard-coded values to a pointer. For example, if you are accessing a ROM address, or a known trap-address.
Normally, however, a pointer's value (it's contents) is established when you allocate memory to go with it (for example, when using malloc()).
Or, as Hammer stated, when you initialize the variable to a known, state, like nil.