Suppose we are compiling for a machine with 1-byte characters, 2 bye shorts, 4 bye ints, and 8 byte reals, and with alignment rules that require the address of every primitive data element to be an even multiple of element's size. Suppose further that the compiler is not permitted to reorder fields. How much space will be consumed by the following array?
array [0.9] of record
s : short
c: char
t : short
d : char
r : real
i : integer
okay my book says that there would be holes in a struct, the largest is 8 bytes..so all the data elements would be 8 bytes but would have holes. 8 x 6 = 48 byes.
However my book also says most compilers would devote 20 bytes to every member of an array...48 is larger so would it just be 48 x 10 = 480 bytes?
For memory layout of arrays it says that for arrays of records, it is common for each subsequent element to be aligned at an address appropriate for any type; small holes between consecutive records may result.
Is this talking about the same holes I already mentioned or is there also holes between the elements of the array?
Thanks
General Discussion
- Caffeine Lounge
- Corner Cubicle
- Student Campus
- Software Development
- Industry News
- Introduce Yourself
- Nightmare.In.Code
Programming Help
- C and C++
- VB.NET
- Java
- C#
- Python
- PHP
- Mobile Development
- ASP.NET
- .NET Framework
- Ruby
- Game Development
- Assembly
- Databases
- ColdFusion
- VB6
- Other Languages
- 52 Weeks Of Code
Web Development
- Web Development
- HTML & CSS
- JavaScript
- Graphic Design
- Flash & ActionScript
- Blogging
- SEO & Advertising
- Web Servers & Hosting
- Site Check
Follow & Share
Tutorials
Programming
- C++ Tutorials
- Java Tutorials
- VisualBasic Tutorials
- VB.NET Tutorials
- C# Tutorials
- PHP Tutorials
- ColdFusion Tutorials
- Database Tutorials
Web Development
Reference Sheets
Code Snippets
- C Snippets
- C++ Snippets
- Java Snippets
- Visual Basic Snippets
- C# Snippets
- VB.NET Snippets
- ASP.NET Snippets
- PHP Snippets
- Python Snippets
- Ruby Snippets
- ColdFusion Snippets
- SQL Snippets
- Assembly Snippets
- Functional Programming Snippets
- Perl Snippets
- HTML/CSS Snippets
- Javascript Snippets
- Flash/ActionScript Snippets
- ASP Snippets
- Linux, Unix, and Bash Snippets
- Other Languages Snippets
- Regex

New Topic/Question
Reply



MultiQuote
|