Çë½ÌCһѡÔñÌâ - C/C++ / CÓïÑÔ
11. Éètypedef struct{int a;char s[10]£»} TYPE£»
TYPE u1£»
Ôòprintf£¨¡®¡®£¥d\n¡±,sizeof£¨u1£©£©£»µÄÊä³ö½á¹ûÊÇ£¨ £©
A. 2 B. 12
C. 14 D. 16
СµÜÎÒ¶Ôº¯ÊýÖеÄsizeof(u1)²»Ã÷°×£¬Ò²²»ÔõôÇå³þsizeofº¯ÊýµÄÓÃÒâ
googleÏÂsizeof£¬È»ºó½Ó×ÅgoogleÄÚ´æ¶ÔÆë
½ñÌìÉÏ¿ÎÎÒÀÏʦ˵ÊÇ4£¬
±ð˵ÊÇÎÒ˵µÄ°¡¡£¡£¡£¡£
°Ù¶È ½á¹¹ÌåµÄÄÚ´æ¶ÔÆë¡£
VCÖÐÊÇD´ð°¸
ÄÚ´æ¶ÔÆëÊÇ¿ÉÒÔÉèÖõġ£
D. 16
sizeof·µ»ØTYPEÀàÐÍËùÕ¼µÄÄÚ´æ×Ö½ÚÊý¡£
Á½ÕßÖ®ºÍΪ14£¬ÎÒ²»Ã÷°××îÖÕ½á¹ûÔõô»áÊÇ16£¿Íû¸ßÊֻشð£¡
ÒÀÀµÓÚƽ̨£¬ÒÀÀµÓÚ±àÒëÑ¡ÏÕâ¸öÌâÄ¿²»ÑϽ÷£¬Ä¿µÄÓ¦¸ÃÊÇ¿¼×Ö½Ú¶ÔÆë
ËÑË÷ #pragma pack()
ÄÚ´æ¶ÔÆë¡£¡£¡£¡£¡£Ñ¡D¡£¡£¡£
°´4µÄ±¶Êý¶ÔÆë
D. 16
ÄÚ´æ¶ÔÆë
ѧϰÁË£¬ÔÀ´»¹ÓÐÄÚ´æ¶ÔÆëÕâÒ»»ØÊ°¡
±àÒëÆ÷Óйأ¡
gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5)
ÉÏÊÇ16.
²»¹ýÎÒ¾õµÃtc2.0»áÊÇ12
Õâ¸öºÍ±àÒëÆ÷ÓйصÄÀ²...
ĬÈÏÄÚ´æ¶ÔÆë4ÊÇ×Ö½Ú¶ÔÆë
0000
0000
0000
00XX
XXÊÇ×Ô¶¯²¹ÆëµÄ£¬¹ØÓÚÄÚ´æ¶ÔÆëÊÇ¿ÉÒÔÉèÖõģ¬ºÃÏñÊÇprogram pack£¨N£©N±íʾÒÔ¼¸×Ö½Ú¶ÔÆ룬Èç¹ûNµÈÓÚ1ÄÇôÄãµÄsizeof£¨ul£©¾ÍµÈÓÚ14
16
µ«ÊÇÖÁÓÚÄÚ´æ¶ÔÆ룬ÎÒ¾õµÃ²¢²»½ö½öÖ»ÊÇ4µÄ±¶ÊýÕâô¼òµ¥£¬
ÄÚ´æ¶ÔÆëµÄ±¶ÊýÓ¦¸ÃÊÇÄãËù¶¨ÒåµÄ½á¹¹ÌåÖж¨ÒåµÄ×î´óµÄÄǸöÀàÐ͵ķÖÃű¶Êý¡£
for example:
struct XX{
double a;
char b[2];
}x;
sizeof(x)=16;¶ø²»ÊÇ12.¡£¡£
ºÇºÇ£¬¸öÈËÖ®¼û£¬Äã×Ô¼º¿ÉÒÔÊÔÒ»ÏÂ...
ÄÚ´æ¶ÔÆë·´Ó¦Á˱àÒëÆ÷¶ÔÓÚÄÚ´æµ
Ïà¹ØÎÊ´ð£º
ÔÚ¸ùĿ¼/libÖдæ·ÅÒ»¸ölog.c£¬log.h£¬²¢ÓÃÏÂÃæµÄÓï¾ä£º
gcc -c log.c
ar crv liblog.a log.o
±àÒë³öÒ»¸öliblog.a¾²Ì¬¿â£¬È»ºóÔÚÎļþ¼Ð£º/testfileÖд´½¨Ò»¸ötest.cºÍtestc.c£¬test.cÖÐÒýÓÃÁËtestc.cÖж¨ÒåµÄ·½·¨ ......
ΪʲôÎҵijÌÐòµ÷ÓÃXMLÅäÖÃÎļþÖеİ¢À²®ÎÄÏÔʾ²»³öÀ´£¿ÆäËûµÄÓïÖÖ¶¼¿ÉÒÔ£¬ÈçÖÐÎÄ£¬Ó¢ÎÄ£¬µÂÎĶ¼¿É¡£
ÎÒ½«XMLµÄ±àÂë¸ÄΪutf-8ºÍunicodeµÄµ½µÃ½á¹û¶¼Ò»Ñù.
°¢À²®ÎĵÄ×Ö¿âÄãÓÐô£¿
ÓÐ,ÎÒµÄEXEÊÇ·ÅÔÚpc»úÉÏÖ´Ðе ......
ÎÒ¸Õ°ÑÌ·ºÆÇ¿µÄµÚÈý°æµÄÊéѧÍ꣬ÎÒÖªµÀµÄÓÐC++£¬CºÍÖ¸Õë CȱÏݺÍÏÝÚå Cר¼Ò±ä³É£¬»¹ÓÐÊý¾Ý½á¹¹£¬ÎÒÏëÎÊÎÊÎÒÓ¦¸ÃÒÔʲô˳ÐòÀ´Ñ§ÄØ
CȱÏݺÍÏÝÚå Cר¼Ò±à³Ì
Êǽø½×µÄ£¬²»Óü±×Å¿´
ÖÁÓÚ
CºÍÖ¸Õë
Äã²»Àí½âÖ ......
[align=center][/align]CÓïÑÔÖÐÈçºÎÅжÏÒ»¸ödoubleÐ͵ÄÊý×飨Èçdouble S[20]£»£©ÊÇÒ»¸ö¿ÕÊý×飬¼´Êý×éÖÐûÓзÅÈκÎÖµ¡£
û°ì·¨¡£
"ÈκÎÖµ" µÄ¶¨Òå?
¾ÍÊÇÊý×éÊǿյģ¬Ã»ÓÐΪËü¸³Öµ
¿ÉÒÔ¿¼Â ......
A±í ÓÐÁ½¸ö×Ö¶Î
id ΨһÊý×ÖÓò
InfoTxt text ÀàÐÍ
ÎÒÏÖÔÚÒª°Ñ id ²»ÊÇ14 µÄËùÓÐ InfoTxt×ֶΠÎı¾ºóÃæ ¶¼¼ÓÉÏ 'aaa'
°´ÏÂÃæÖ´ÐÐÏÂÀ´ Ö»Óбí×îºóÒ»ÐмÓÉÏÁË 'aaa' ......