Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with a problem

Status
Not open for further replies.

CindyCSCK

Programmer
Jan 15, 2002
4
DE
If an int datatype is stored in two bytes on a given system, The How many bytes of memory would the following array use?

int stuff[45][5];
 
Assuming sizeof(int) is equal to 2 then 450 is right. It can, however, be bad to make assumptions and it has jumped up and bit me in the behind a few times. Now, whenever I use a type I use that type in my size calculation. For the above I would output

cout<<45*5*sizeof(int)<<endl;


Just my 2 cents

Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top