Re: Question



DarkD said:

> Im not sure you fully understand a pointer.

I'm not sure you do. :-)

> He is pointing to that memory
> location and displaying the integer value from that location. If you did
> this:
>
> int x;
> x = *&0x00c0;
> printf("Value at address 0x00c0 is %d\n",x);

You meant that to be:

int x;
x = *(int *)0x00c0;
printf("Value at address 0x00c0 is %d\n",x);


The code is, of course, non-portable, but may work anyway on some systems.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/2005
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
.



Relevant Pages

  • Re: object creation and naming at runtime?
    ... >>replaced with memory references by the compiler. ... I don't know where the computer will allocate space in ... memory for my int so I'll use a name for the address and let ... In the source code the pointer object (which will ...
    (alt.comp.lang.learn.c-cpp)
  • Re: 2-dimensional arrays and functions
    ... > int* foo ... >> that return memory addresses. ... >> You obviously don't know the difference between a pointer and a memory ... > address of the dynamically allocated memory is stored. ...
    (alt.comp.lang.learn.c-cpp)
  • Re: FIFO Problem
    ... text but a *pointer* to some text. ... pointing to the string in the clients memory. ... if you want to pass a string from one process to the other then ... int length; ...
    (comp.os.linux.development.apps)
  • Re: 2D array of structures
    ... Don't cast the return value of malloc(), ... you allocate here memory for 7 such structures. ... a pointer to the start of this memory, which is of type 'STRUCTURE *' ...
    (comp.lang.c)
  • Re: contiguity of arrays
    ... > consecutive integers and know the address of the first integer, ... No matter how I come into ownership of this memory. ... choose to represent a pointer as an address and a length; ... > type int. ...
    (comp.lang.c)