C struct ÖÐ×Ö½Ú¶ÔÆëÎÊÌâ
VCÖÐÏÂÃ漸¸ö½á¹¹Ìå´óС·Ö±ðÊǶàÉÙÄØ
struct MyStruct
{
double m4;
char m1;
int m3£»
};
struct MyStruct {
char m1;
double m4;
int m3;
};
#pragma pack(push)//±£´æ¶ÔÆë״̬
#pragma pack(16) //ÉèÖÃΪ16×Ö½Ú¶ÔÆë
struct test
{
char m1;
int m3;
double m4;
};
#pragma pack(pop)//»Ö¸´¶ÔÆë״̬
Èç¹ûÄãµÄ´ð°¸²»ÊÇ16£¬24ºÍ16£¬ÏàÐÅÏÂÃæµÄÄÚÈݶÔÄãºÜÓаïÖú¡£
1¡¢ sizeofÓ¦ÓÃÔڽṹÉϵÄÇé¿ö
Çë¿´ÏÂÃæµÄ½á¹¹£º
struct MyStruct
{
double dda1;
char dda;
int type
};
¶Ô½á¹¹MyStruct²ÉÓÃsizeof»á³öÏÖʲô½á¹ûÄØ£¿sizeof(MyStruct)Ϊ¶àÉÙÄØ£¿Ò²ÐíÄã
»áÕâÑùÇó£º
sizeof(MyStruct)=sizeof(double)+sizeof(char)+sizeof(int)=13
µ«Êǵ±ÔÚVCÖвâÊÔÉÏÃæ½á¹¹µÄ´óСʱ£¬Äã»á·¢ÏÖsizeof(MyStruct)Ϊ16¡£ÄãÖªµÀΪʲ
ôÔÚVCÖлáµÃ³öÕâÑùÒ»¸ö½á¹ûÂð£¿
Æäʵ£¬ÕâÊÇVC¶Ô±äÁ¿´æ´¢µÄÒ»¸öÌØÊâ´¦Àí¡£ÎªÁËÌá¸ßCPUµÄ´æ´¢Ëٶȣ¬VC¶ÔһЩ±äÁ¿µÄ
ÆðʼµØÖ·×öÁË“¶ÔÆë”´¦Àí¡£ÔÚĬÈÏÇé¿öÏ£¬VC¹æ¶¨¸÷³ÉÔ±±äÁ¿´æ·ÅµÄÆðʼµØÖ·Ïà¶ÔÓÚ½á
¹¹µÄÆðʼµØÖ·µÄÆ«ÒÆÁ¿±ØÐëΪ¸Ã±äÁ¿µÄÀàÐÍËùÕ¼ÓõÄ×Ö½ÚÊýµÄ±¶Êý¡£ÏÂÃæÁгö³£ÓÃÀàÐ͵Ä
¶ÔÆ뷽ʽ(vc6.0,32λϵͳ)¡£
ÀàÐÍ ¶ÔÆ뷽ʽ£¨±äÁ¿´æ·ÅµÄÆðʼµØÖ·Ïà¶ÔÓڽṹµÄÆðʼµØÖ·µÄÆ«ÒÆÁ¿£©
Char Æ«ÒÆÁ¿±ØÐëΪsizeof(char)¼´1µÄ±¶Êý
Short Æ«
Ïà¹ØÎĵµ£º
ת£ºhttp://school.ogdev.net/ArticleShow.asp?categoryid=10&id=6019
º¯ÊýÖ¸ÕëÊý×éµÄÃîÓÃ
±ÊÕßÔÚ¿ª·¢Ä³Èí¼þ¹ý³ÌÖÐÓöµ½ÕâÑùÒ»¸öÎÊÌ⣬ǰ¼¶Ä£¿é´«¸øÎÒ¶þ½øÖÆÊý¾Ý£¬ÊäÈë²ÎÊýΪ char* bufferºÍ int length£¬bufferÊÇÊý¾ÝµÄÊ×µØÖ·£¬length±íʾÕâÅúÊý¾ÝµÄ³¤¶È¡£Êý¾ÝµÄÌصãÊÇ£º³¤¶È²»¶¨£¬ÀàÐͲ»¶¨£¬ÓɵÚÒ»¸ö×Ö½Ú£¨buffer[0] ......
ÊÂÇéÓ¦¸Ã±»×öµÃ¾¡¿ÉÄܵļòµ¥£¬µ«²»ÊÇÈÎÒâµØ¼òµ¥»¯¡£
¨D¨D°®Òò˹̹
ËäÈ»×öºÃµÄ³ÌÐòÄÜ°´ÏîÄ¿ÐèÇóÕýÈ·ÔËÐе½×îºóÒ»²½£¬µ«ÔÚǶÈëʽϵͳ¿ª·¢Öв¢²»×ÜÊÇÄܳɹ¦µÄ¡£ÓÉÓڵͳɱ¾µÄÐèÒªÓ²¼þÉè¼ÆÕß¼¸ºõ²»¿ÉÄÜÉè¼Æ³ö×ã¹»µÄÄÚ´æºÍ´¦ÀíÆ÷ÐÔÄÜÀ´Ê¹µÃ³ÌÐòÄܱ»ÔËÐС£µ±È»£¬ÔÚÈí¼þ¿ª·¢¹ý³ÌÖÐʹµÃ³ÌÐòÄܹ»ÕýÈ·ÔËÐÐÊǸüÖØÒªµÄ¡£ÎªÁËÕâµã£¬Í¨³£ ......
This is Edition 2.2.10 of `The `indent' Manual', for Indent Version
2.2.10, last updated 23 July 2008.
Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996 Free Software
Foundation, Inc. Copyright (C) 1995, 1996 Joseph Arceneaux. Copyright
(C) 1999 Carlo Wood. Copyright (C) 2001 David Ingamell ......
½ñÌì±È½ÏÀÁ¶è£¬Ã»×öÌ⣬ֻÊÇ¿´ÁËÒ»µãÄDZ¾cÏÝÚåÓëȱÏÝ£¬ËµÊµ»°¶ÁÁ˲»¶àµ«Ã÷ÏÔÄܸоõ³öÕâÊÇÒ»±¾ºÃÊ飬¸Ð¾õ¶ÔÎÒÀ´Ëµ¸ÕºÃ£¬²»ÊÇ»ù´¡Ê飬µ«Ò²»ù±¾ÄÜ¿´¶®£¬¶øÇÒÄÜѧµ½ºÃ¶à¶«Î÷£¬µ«½ñÌìÖ»¿´ÁËÈýÕ£¬Ö÷ÒªÊÇϾüÆìÁË£¬囧£¬ÎÒÒ²Ö»ÄÜ°ÑÎÒѧµ½µÄ×ܽáÏÂÀ´£¬Ñ§ÁË×ܱÈÒ»µã¶¼Ã»Ñ§ÒªºÃ£¬ÎÒÒ²Ö»ÄÜÕâÑù°²Î¿×Ô¼ºÁË¡£ ......
1.ÒýÑÔ ±¾ÎĵÄд×÷Ä¿µÄ²¢²»ÔÚÓÚÌṩC/C++³ÌÐòÔ±ÇóÖ°ÃæÊÔÖ¸µ¼£¬¶øÖ¼ÔÚ´Ó¼¼ÊõÉÏ·ÖÎöÃæÊÔÌâµÄÄÚº¡£ÎÄÖеĴó¶àÊýÃæÊÔÌâÀ´×Ô¸÷´óÂÛ̳£¬²¿·ÖÊÔÌâ½â´ðÒ²²Î¿¼ÁËÍøÓѵÄÒâ¼û-¡£
Ðí¶àÃæÊÔÌâ¿´ËƼòµ¥£¬È´ÐèÒªÉîºñµÄ»ù±¾¹¦²ÅÄܸø³öÍêÃÀµÄ½â´ð¡£ÆóÒµÒªÇóÃæÊÔÕßдһ¸ö×î¼òµ¥µÄstrcpyº¯Êý¶¼¿É¿´³öÃæÊÔÕßÔÚ¼¼ÊõÉϾ¿¾¹´ïµ½ÁËÔ ......