Lombardo3
|
  |
| Joined: 15 Dec 2012 |
| Total Posts: 271 |
|
|
| 22 Dec 2012 10:40 AM |
| I'm kind of confused with memory address, I read that it label each byte, so to store a 32 bit number, we need 4 addresses? Then how pointers in C work? |
|
|
| Report Abuse |
|
|
| |
|
Lombardo3
|
  |
| Joined: 15 Dec 2012 |
| Total Posts: 271 |
|
|
| 22 Dec 2012 10:45 AM |
| Yeah... Still, I want to know how Pointers point to data bigger than a byte. |
|
|
| Report Abuse |
|
|
| |
|
Lombardo3
|
  |
| Joined: 15 Dec 2012 |
| Total Posts: 271 |
|
| |
|
|
| 22 Dec 2012 10:49 AM |
"memory address" "that it label each byte" "Then how pointers in C work?"
Nah, I'm just pulling your leg. We all have our spelling/grammar fail moments :3
|
|
|
| Report Abuse |
|
|
Lombardo3
|
  |
| Joined: 15 Dec 2012 |
| Total Posts: 271 |
|
| |
|
|
| 22 Dec 2012 10:53 AM |
:( I'll give you a Christmas Cookie if you come back... |
|
|
| Report Abuse |
|
|
Lombardo3
|
  |
| Joined: 15 Dec 2012 |
| Total Posts: 271 |
|
| |
|
essu8
|
  |
| Joined: 26 Nov 2012 |
| Total Posts: 49 |
|
|
| 22 Dec 2012 10:55 AM |
>Yeah... Still, I want to know how Pointers point to data bigger than a byte.
pointers point to the first byte of the data |
|
|
| Report Abuse |
|
|
myrkos
|
  |
| Joined: 06 Sep 2010 |
| Total Posts: 8072 |
|
|
| 22 Dec 2012 10:57 AM |
| This is done by having the pointer point to the first byte of the int/word/float/whatever. |
|
|
| Report Abuse |
|
|
|
| 22 Dec 2012 10:57 AM |
*gives cookie*
essu8 is correct. They just point to the first byte. |
|
|
| Report Abuse |
|
|
Lombardo3
|
  |
| Joined: 15 Dec 2012 |
| Total Posts: 271 |
|
|
| 22 Dec 2012 10:57 AM |
| And how do they know when the sequence is over? |
|
|
| Report Abuse |
|
|
myrkos
|
  |
| Joined: 06 Sep 2010 |
| Total Posts: 8072 |
|
|
| 22 Dec 2012 10:58 AM |
| Since C is statically typed, it knows the size of all the types at compile time. |
|
|
| Report Abuse |
|
|
essu8
|
  |
| Joined: 26 Nov 2012 |
| Total Posts: 49 |
|
|
| 22 Dec 2012 10:58 AM |
| the size of the data in bytes must be known |
|
|
| Report Abuse |
|
|
|
| 22 Dec 2012 10:59 AM |
| If I might ask, what are you making in C? |
|
|
| Report Abuse |
|
|
Lombardo3
|
  |
| Joined: 15 Dec 2012 |
| Total Posts: 271 |
|
|
| 22 Dec 2012 11:00 AM |
| Everything is clearer now, thanks. |
|
|
| Report Abuse |
|
|
Lombardo3
|
  |
| Joined: 15 Dec 2012 |
| Total Posts: 271 |
|
|
| 22 Dec 2012 11:02 AM |
| Nothing, I was googling about memory and found that each address holds one byte, so I asked myself "Then how does pointers point to data bigger than one byte?" and the rest is history. |
|
|
| Report Abuse |
|
|
booing
|
  |
| Joined: 04 May 2009 |
| Total Posts: 6594 |
|
|
| 22 Dec 2012 03:11 PM |
| It knows to stop reading when there is \0 |
|
|
| Report Abuse |
|
|
Flurite
|
  |
| Joined: 03 Apr 2011 |
| Total Posts: 5386 |
|
|
| 22 Dec 2012 03:22 PM |
| booing, isn't that only for chars? |
|
|
| Report Abuse |
|
|
UnAdmin
|
  |
| Joined: 10 Jul 2012 |
| Total Posts: 4706 |
|
|
| 22 Dec 2012 05:26 PM |
I never get a cookie :(
~Yea, you could rub some bacon on it... or... add a debounce to it! |
|
|
| Report Abuse |
|
|
|
| 23 Dec 2012 11:50 AM |
@booingggg
thats only for C style strings.
and it reads something in an array like
arrayPointer + (offsetInArray * objectSize) (note: it might be that the *objectSize isnt needed in C++/C because it might do it automatically if the arrayPointer is of some type. like if its array of 32 bit ints, +1 would go 4 addresses forward or something.) |
|
|
| Report Abuse |
|
|