Click here to Skip to main content
15,880,608 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionvideo ram Pin
samira forooghi12-Jul-06 1:55
samira forooghi12-Jul-06 1:55 
AnswerRe: video ram Pin
includeh1012-Jul-06 2:48
includeh1012-Jul-06 2:48 
QuestionRe: video ram Pin
David Crow12-Jul-06 2:54
David Crow12-Jul-06 2:54 
AnswerRe: video ram Pin
Hamid_RT12-Jul-06 3:21
Hamid_RT12-Jul-06 3:21 
Questionsame structure behave differntly in different application Pin
pavan105nagarbhavi12-Jul-06 1:48
pavan105nagarbhavi12-Jul-06 1:48 
AnswerRe: same structure behave differntly in different application Pin
_AnsHUMAN_ 12-Jul-06 2:16
_AnsHUMAN_ 12-Jul-06 2:16 
QuestionRe: same structure behave differntly in different application Pin
David Crow12-Jul-06 2:59
David Crow12-Jul-06 2:59 
AnswerRe: same structure behave differntly in different application Pin
Zac Howland12-Jul-06 3:41
Zac Howland12-Jul-06 3:41 
pavan105nagarbhavi wrote:
struct lat_lon1 {
char news;
short deg;
short min;
float sec;
}lat;


With the default compiler switches/directives, this structure will be packed as follows:

struct lat_lon1 
{
	char news;	// 1 byte
	char junk1;	// 1 byte
	short deg;	// 2 bytes and must be on 2-byte boundary
	short min;	// 2 bytes and must be on 2-byte boundary
	short junk2;	// 2 bytes and must be on a 2-byte boundary
	float sec;	// 4 bytes and must be on a 4-byte boundary
}lat;


That is where you get the sizeof(lat_lon1) == 12 from. Now, with some varying directives (#pragma pack for example), you could get it packed as follows:

struct lat_lon1 
{
	float sec;	// 4 bytes and must be on a 4-byte boundary
	char news;	// 1 byte
	char junk1;	// 1 byte
	short deg;	// 2 bytes and must be on 2-byte boundary
	short min;	// 2 bytes and must be on 2-byte boundary
}lat;


which would give you sizeof(lat_lon1) == 10. This is a very good example of why it is important to declare variables in a certain order for complex types.

If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week

Zac
QuestionRegistry - RegSetValuEx - Returning Access denied ?? Pin
elitecodex12-Jul-06 1:43
elitecodex12-Jul-06 1:43 
AnswerRe: Registry - RegSetValuEx - Returning Access denied ?? Pin
Steve S12-Jul-06 3:11
Steve S12-Jul-06 3:11 
GeneralRe: Registry - RegSetValuEx - Returning Access denied ?? [modified] Pin
elitecodex12-Jul-06 4:51
elitecodex12-Jul-06 4:51 
GeneralRe: Registry - RegSetValuEx - Returning Access denied ?? Pin
Steve S12-Jul-06 6:51
Steve S12-Jul-06 6:51 
QuestionProblem with size of child window Pin
g_sandipan12-Jul-06 1:16
g_sandipan12-Jul-06 1:16 
AnswerRe: Problem with size of child window [modified] Pin
Sarath C12-Jul-06 1:29
Sarath C12-Jul-06 1:29 
GeneralRe: Problem with size of child window Pin
g_sandipan12-Jul-06 2:00
g_sandipan12-Jul-06 2:00 
Questionpressing return in an edit control Pin
Desmo1612-Jul-06 0:38
Desmo1612-Jul-06 0:38 
AnswerRe: pressing return in an edit control Pin
Sarath C12-Jul-06 0:45
Sarath C12-Jul-06 0:45 
GeneralRe: pressing return in an edit control [modified] Pin
see me12-Jul-06 1:13
see me12-Jul-06 1:13 
GeneralRe: pressing return in an edit control Pin
Hamid_RT12-Jul-06 1:16
Hamid_RT12-Jul-06 1:16 
GeneralRe: pressing return in an edit control Pin
Sarath C12-Jul-06 1:27
Sarath C12-Jul-06 1:27 
GeneralRe: pressing return in an edit control Pin
FarPointer12-Jul-06 1:49
FarPointer12-Jul-06 1:49 
AnswerRe: pressing return in an edit control Pin
Naveen12-Jul-06 0:47
Naveen12-Jul-06 0:47 
GeneralRe: pressing return in an edit control Pin
Naveen12-Jul-06 1:11
Naveen12-Jul-06 1:11 
AnswerRe: pressing return in an edit control Pin
ThatsAlok12-Jul-06 0:57
ThatsAlok12-Jul-06 0:57 
AnswerRe: pressing return in an edit control Pin
Hamid_RT12-Jul-06 1:02
Hamid_RT12-Jul-06 1:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.