Sponsored Content
Top Forums Programming Address Alignment rules for structure variables Post 49094 by anijog on Wednesday 24th of March 2004 11:49:07 PM
Old 03-25-2004
Java Address Alignment rules for structure variables

Hi,

This question might look naive, but I need to know address alignment rules used by O/S, hence posting this one.

I've following 2 structures :-

struct xyz {
char a;
int b;
char c;
}

struct abc {
char a;
char c;
int b;
}


If I print size of these 2 structures using sizeof() operator, it is 12 for xyz & 8 for abc. This is consistent on 32 as well as 64 bit machines (I'm using HP-UX).

Both structures have some no of elements of same type, only they differ in order of definition.

Then why is that size of struct xyz is 12 where as that of struct abc is 8 ?

What are precise rules for address alignment ?

Thanks in advance
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Copying a Directory Structure to a new structure

Hi all Is it possible to copy a structure of a directory only. e.g. I have a file with the following entries that is a result of a find :- /dir1/dir2/file.dbf /dir1/dir2/dir3/file1.dbf /dir1/file.dbf I want to copy these to a directory and keep the structure however starting at a new dir... (8 Replies)
Discussion started by: jhansrod
8 Replies

2. Programming

how to round up a memory address(memory alignment problem)

Hi, I try to marshal a unsigned int and a char * into a buffer, and then unmarshal them later to get them out. I need to put the char * in the front and unsigned int at the end of the buffer. However, my system always give me "BUS ERROR". I am using Sun Sparcs Sloris 2.10. My code to marshal... (6 Replies)
Discussion started by: nj302
6 Replies

3. UNIX for Advanced & Expert Users

MV files from one directory structure(multiple level) to other directory structure

Hi, I am trying to write a script that will move all the files from source directory structure(multiple levels might exist) to destination directory structure. If a sub folder is source doesnot exist in destination then I have to skip and goto next level. I also need to delete the files in... (4 Replies)
Discussion started by: srmadab
4 Replies

4. Programming

Search attributes in one structure using the values from another structure

Hello Groups I am trying to find out ways of comparing a value from a 'c' structure to a value in another 'C' structure. the 'C' structure can be a List or liked list as it contains lot many records. if we loop it in both the structures it is going to consume time. I am looking for a simple... (3 Replies)
Discussion started by: dhanamurthy
3 Replies

5. Shell Programming and Scripting

alignment of variable

Dear Champs, i have a file let a.txt having value number text 00 123 012 145 456 ...etc i need number and text column vales should right align ??? how can i achive this ??? NOTE number is of max 3 char and text can take max 7 char...so if any records are less than above lengths... (2 Replies)
Discussion started by: manas_ranjan
2 Replies

6. UNIX for Dummies Questions & Answers

VI paste out of alignment

We have a guy at work who is trying to copy and paste from one file to another using vi and highlighting the code to copy with a mouse. Source file: xyz 123 abc 999 zyx 321 cba 999 xyz 123 abc 999 But when he pastes it he gets (I put the underlines in to show... (4 Replies)
Discussion started by: dlam
4 Replies

7. Shell Programming and Scripting

alignment

Hi, I am having a file with with format. however, for longer xml, the xml code has been truncated like this. F1 |###################### |String1 |<XML><REQ><MSGTYPE>DBDIRECT</MSGTYPE><SYNC>0</SYNC><CLIENT>C11</CLIENT>NAME=MYNAME|JOB=MYJOB| | ... (3 Replies)
Discussion started by: shellwell
3 Replies

8. HP-UX

HP-UX text alignment

HI all, I tried to edit my files using HP-UX but my output tends to not align when I add another character in the files to edit my files i used the command is as follow chmod +w filename vi filename Help, :eek: (1 Reply)
Discussion started by: jasonhpwong
1 Replies

9. UNIX for Beginners Questions & Answers

Help with awk alignment

Dear All, I am in the beginning stage of learning shell scripting and preparing shell script on my own now. I would like to get help from fellow mates here. As I am trying to take O/P with space included from I/P table. Kindly guide me to align given I/P table as Expected O/P. ... (5 Replies)
Discussion started by: Raja007
5 Replies
FileChooser(3I)                                             InterViews Reference Manual                                            FileChooser(3I)

NAME
FileChooser - dialog box for choosing a file name SYNOPSIS
#include <InterViews/filechooser.h> DESCRIPTION
FileChooser is a StringChooser that provides a complete dialog box interface to selecting a file name. The interface consists of two lines of descriptive text, a StringEditor for entering the file name explicitly, a FileBrowser, and two PushButtons, one for accepting and one for canceling the dialog. PUBLIC OPERATIONS
FileChooser(const char* title, const char* subtitle, const char* dir, int rows, int cols, const char* acceptLabel, Alignment) FileChooser(const char* name, const char*, const char*, const char*, int, int, const char* accept, Alignment) Construct a new FileChooser with the given title and subtitle, search directory dir, FileBrowser size specification rows and cols, label for the accept PushButton acceptLabel, and pop-up alignment. These constructors create all the elements of the dialog box and compose them into a default layout. void SetTitle(const char*) void SetSubtitle(const char*) Change the text in title or the subtitle. The new text will appear immediately in the dialog when either function is called. void SelectFile() Highlight the text in the StringEditor. void Update() FileChooser's Update simply calls Update on the FileBrowser instance to rescan the current directory and update its appearance. PROTECTED OPERATIONS
FileChooser(ButtonState*, Alignment = Center) Construct a new FileChooser with the given button state and pop-up alignment without creating FileBrowser, StringEditor, title, sub- title, or PushButton instances. This constructor should be called in subclasses requiring a specialized StringEditor or File- Browser. FileChooser(ButtonState*, const char* dir, int rows, int cols, Alignment) Construct a new FileChooser (along with its StringEditor and its FileBrowser) with the given button state, search directory, File- Browser size specification, and pop-up alignment without composing them into the default layout and without creating the title, sub- title, or PushButtons. This constructor should be used by FileChooser subclasses that define a specialized look and feel. SEE ALSO
Button(3I), Dialog(3I), FileBrowser(3I), StringChooser(3I), StringEditor(3I) InterViews 30 November 1989 FileChooser(3I)
All times are GMT -4. The time now is 12:45 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy