473,396 Members | 1,689 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

width of memory

how can i know the width of memory in a c program??
Jun 29 '07 #1
3 1324
r035198x
13,262 8TB
how can i know the width of memory in a c program??
What do you mean by that ?
Jun 29 '07 #2
What do you mean by that ?
my understanding is that,in memory each cell is arranged in rows and columns.The cpu accesses memory by sending the memory address on the address bus i.e the higher order byte indicating the row and lower order byte the column.I want to know the width in the sense,number of columns.Does this width have an effect on the arrangement of a structure in memory.for ex i have a structure which has an int and a char:
struct a{
int a;
char b;
};
how are the members of struct present in memory,also if i say char occurs first and int next how will it be in memory.Taken the size of int is 32 and char is 1 byte.Does the int sit in a row which has 32 columns i.e width of memory.
Jun 29 '07 #3
weaknessforcats
9,208 Expert Mod 8TB
I think you are talking about alignment here.

There are no rows and columns in memory. The address space is flat. The locations are numbered from 0 to n. In a strip, like the frames in movie film.

Each location is a byte.

The processor, say a 32-bit porcessor, should have the data aligned on 32-bit boudaries for efficiency. The compilere tries to support this. So, this struct:
Expand|Select|Wrap|Line Numbers
  1. struct X
  2.    int a;
  3.    char b;
  4.    int c;
  5. };
  6.  
will have a on a 32-bit boudary (called a word boundary). b will also be on the next 32-bit boundary. But b is just one bye. Therefore, the compiler will add three pad bytes after b so that c is aligned on a 32-bit boundary.

This is to say the sizeof a struct ns not necessarily the same as the sum of the sizes of its members.

All of this is logical mapping and has no relation to the physical memory location. The OS will convert the logical addresses to the physical addresses.
Jun 29 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Garrett Albright | last post by:
I'm searching through PHP's GD functions , and, unless I'm totally blind, I can't find a function that will calculate the size of a GD image in memory; only getimagesize() , which only works with...
17
by: BenOne© | last post by:
Hi all, For divs, do all browsers treat these the same? I've been assuming that width and height are inclusive of margin and padding, but the different appearance of my page in various...
4
by: RelaxoRy | last post by:
I have 2 screen sizes I want to accomodate for. screen.width <= 800 and > 800. This is because If it's one or the other, I want a different set of menu graphics, and to set variables for my...
15
by: T Koster | last post by:
Hi group, I'm having some difficulty figuring out the most portable way to read 24 bits from a file. This is related to a Base-64 encoding. The file is opened in binary mode, and I'm using...
0
by: Stuart | last post by:
Hi there Someone please put me out of my misery... I am attempting to offer a graphical view of some data in an aspx page by using the width property of some colored text boxes. The data is...
1
by: PLSH | last post by:
Good day, I hope some one can help. I would like to programmatically set the width of my webform datagrid columns. Preferably to a set width or otherwise to autofit the entire datagrid. Please...
1
by: eayoung | last post by:
I am using Access 2003 on a Dell XPS 400 with 512MB of video memory and side-by-side 20" monitors. It's a wonderful way to have the VB code on one side and the Access app on the other - but it has...
2
by: bizt | last post by:
Hi, Is it possible to obtain the width/ height of an image when that image is dyanically created using a PHP script and passing GET attributes. For example: <img...
28
by: Piotrek | last post by:
<<If this message is duplicated, please ignore the previous one, I had some connection problems>> Hi, Could you please tell me how to check width and height of Windows console program...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.