Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Jul 8th, 2007, 9:09 PM   #1
357mag
Hobbyist Programmer
 
Join Date: Mar 2005
Posts: 148
Rep Power: 4 357mag is on a distinguished road
Hexadecimal Memory Address Question

I've got this program that just shows a little bit about pointer arithmetic. Using an array and a pointer, I just output the memory address of the first element using the pointer, then I incremented the pointer by 1 to output the next memory address, then I incremented the pointer by 1 again to output the next memory address. Then I used a second pointer and assigned it the memory address of the last element in my array. Then I outputted the memory address of that. I had to do a little digging in my book to try to understand the output. Here it is:

0012FF54
0012FF58
0012ff5C
0012ff60

I was using an integer array so the elements were 4 bytes. Going from the first element to the second, I understood the 4 moving to the 8, makes sense to me. Moving from the second element to the third, I did not understand the 8 moving to the C. But then I did a little reading on hexadecimal numbering and I think I understand why now. Hexadecimal has 16 digits, but when you get to 10 then you say A, 11 is B, 12 is C. So moving 4 bytes up from 8 would land you precisely on the letter C.

Then to understand moving from the third element to the last element you count again starting at C, D is one beyond that, E is two beyond that, F is three beyond that, and then finally back to 0 would land you at 4 bytes beyond that. So that's how I got it figured.

My question is moving from the 5 to the 6(in the third to the fourth element).
Is this just simply the way it works? It's just simply the way the consecutive elements would be numbered? And just accept it for what it is and not try to analyze it too much?
357mag is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Virtual Memory question metsfan C 2 Apr 11th, 2006 6:47 PM
When to use the new keyword in C++? titaniumdecoy C++ 28 Mar 16th, 2006 12:36 PM
Pointers in C (Part II) Stack Overflow C 2 Apr 29th, 2005 10:39 AM
Pointers in C (Part I) Stack Overflow C 4 Apr 28th, 2005 7:03 PM
memory leak question xaosai C++ 2 Mar 31st, 2005 10:25 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:33 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC