455,128 Members | 1,224 Online Need help? Post your question and get tips & solutions from a community of 455,128 IT Pros & Developers. It's quick & easy.

# memory selection

 P: n/a Hello why is it that the lower index in an array occupies the highest number address. e.g. #include using namespace std; int main() { int a; cout << "sizeof(int) = "<< sizeof(int) << endl; for(int i = 0; i < 10; i++) cout << "&a[" << i << "] = " << (long)&a[i] << endl; } sizeof(int) = 4 &a = -1073743552 why not start 3516 &a = -1073743548 &a = -1073743544 &a = -1073743540 &a = -1073743536 &a = -1073743532 &a = -1073743528 &a = -1073743524 &a = -1073743520 &a = -1073743516 and ends with 3552 where the numbers located on the physical drive relative to each other? thanks Jul 31 '05 #1
6 Replies

 P: n/a Baloff sade: Hello why is it that the lower index in an array occupies the highest number address. e.g. The stack usually grows downward. Tobias -- IMPORTANT: The contents of this email and attachments are confidential and may be subject to legal privilege and/or protected by copyright. Copying or communicating any part of it to others is prohibited and may be unlawful. Jul 31 '05 #2

 P: n/a Baloff wrote: why is it that the lower index in an array occupies the highest number address. e.g. Do you know negative numbers? -- Salu2 Jul 31 '05 #3

 P: n/a On 01 Aug 2005 07:11:34 +1000, Baloff wrote in comp.lang.c++: Hello why is it that the lower index in an array occupies the highest number address. e.g. #include using namespace std; int main() { int a; cout << "sizeof(int) = "<< sizeof(int) << endl; for(int i = 0; i < 10; i++) cout << "&a[" << i << "] = " << (long)&a[i] << endl; ^^^^^^^^^^^ Change this to (unsigned long)&a and prepare to be thrilled and delighted. } sizeof(int) = 4 &a = -1073743552 why not start 3516 &a = -1073743548 &a = -1073743544 &a = -1073743540 &a = -1073743536 &a = -1073743532 &a = -1073743528 &a = -1073743524 &a = -1073743520 &a = -1073743516 and ends with 3552 where the numbers located on the physical drive relative to each other? -- Jack Klein Home: http://JK-Technology.Com FAQs for comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html comp.lang.c++ http://www.parashift.com/c++-faq-lite/ alt.comp.lang.learn.c-c++ http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html Jul 31 '05 #4

 P: n/a "Baloff" wrote in message news:87************@wash.edu... why is it that the lower index in an array occupies the highest number address. e.g. .... &a = -1073743552 why not start 3516 &a = -1073743548 &a = -1073743544 &a = -1073743540 &a = -1073743536 &a = -1073743532 &a = -1073743528 &a = -1073743524 &a = -1073743520 &a = -1073743516 and ends with 3552 Since when is -1073743552 greater than -1073743516? Aug 1 '05 #5

 P: n/a Andrew Koenig wrote: "Baloff" wrote: why is it that the lower index in an array occupies the highest number address. e.g. &a = -1073743552 why not start 3516 &a = -1073743516 and ends with 3552 Since when is -1073743552 greater than -1073743516? I have absolutely no idea. Aug 1 '05 #6

 P: n/a Baloff wrote: Hello why is it that the lower index in an array occupies the highest number address. e.g. #include using namespace std; int main() { int a; cout << "sizeof(int) = "<< sizeof(int) << endl; for(int i = 0; i < 10; i++) cout << "&a[" << i << "] = " << (long)&a[i] << endl; ITYM << &a[i] << endl; Or the not-quite-right: << (unsigned long)&a[i] << endl; } sizeof(int) = 4 &a = -1073743552 why not start 3516 &a = -1073743548 &a = -1073743544 &a = -1073743540 &a = -1073743536 &a = -1073743532 &a = -1073743528 &a = -1073743524 &a = -1073743520 &a = -1073743516 and ends with 3552 where the numbers located on the physical drive relative to each other? `Physical drive'? What's *that*? HTH, --ag -- Artie Gold -- Austin, Texas http://it-matters.blogspot.com (new post 12/5) http://www.cafepress.com/goldsays "If you have nothing to hide, you're not trying!" Aug 1 '05 #7

### This discussion thread is closed

Replies have been disabled for this discussion. 