Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
11/23/02 15:08
Read: times


 
#33008 - RE: Char vs short unsigned int Array
let your array be char and contain (05 04 03 02 01) e.g.
A[0]=05 , A[1]=04 ...
address of the element A[0] is also the base addr. of your array. so when you refer element A[3] infact you are referring address:
(addr(A[0])+3*sizeof(char))
which is base address+(3*1)
since size of char=1 byte.

now let your array be short int then values will be:
(0005,0004,0003,0002,0001)
A[0]=0005 , A[1]=0004 , A[2]=0003 ....
now address of A[3] is again

(addr(A[3])+3*sizeof(short int))=base+(3*2)
since sizeof(short int)=2 bytes.

And this is done by compiler instead of you (as Andy Neil said) so you dont have to bother yourself with these details.

List of 7 messages in thread
TopicAuthorDate
Char vs short unsigned int Array            01/01/70 00:00      
RE: Char vs short unsigned int Array            01/01/70 00:00      
RE: Char vs short unsigned int Array            01/01/70 00:00      
RE: Char vs short unsigned int Array            01/01/70 00:00      
RE: Char vs short unsigned int Array            01/01/70 00:00      
Correction            01/01/70 00:00      
RE: Char vs short unsigned int Array            01/01/70 00:00      

Back to Subject List