Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

C/C++³ÌÐòÖнṹÌå×Ö½ÚÁ÷µÄÍøÂç´«Êä

 ¾­³£ÐèÒªÔÚ³ÌÐòÖн«Ô¶³Ì´«À´µÄ×Ö½ÚÁ÷½øÐнṹ»¯£¬»òÕß½«½á¹¹»¯µÄÊý¾Ý±ä³É×Ö½ÚÁ÷´«¸øÔ¶³ÌÖ÷»ú¡£ÔÚC/C++³ÌÐòÖУ¬½á¹¹»¯Êý¾Ýͨ³£ÓýṹÌåÀ´×éÖ¯£¬½á¹¹ÌåÒ²Äܹ»·½±ãµÄת»»Îª×Ö½ÚÁ÷£¬Òò´Ë½á¹¹»¯µÄÊý¾Ý´«Êä±¾²»¸Ã³ÉΪÎÊÌ⣬µ«ÔÚVC»òGCCµÄĬÈÏÉèÖÃϱàÒë³öµÄ³ÌÐò£¬È´ÓÐÒ»¸öÖµµÃ×¢ÒâµÄÎÊÌâ——½á¹¹ÌåµÄ¶ÔÆë¡£    ½á¹¹ÌåµÄ¶ÔÆëÊDZàÒëÆ÷Ϊ¼Ó¿ì³ÌÐòÔËÐУ¬ÔڽṹÌåÖÐÌîÈëһЩ¿Õ°××Ö½Ú£¬ÊǵĽṹÌå³ÉÔ±°´Ò»¶¨¹æÔò¶ÔÆë¡£
ÀýÈç½á¹¹£º 
struct MyStruct
{    
char a;    
int  b; 
};
  
     °´Ò»°ã¼ÆËãÆäÀàÏ´¹ýÄÇ´óСӦΪ5¸ö×Ö½Ú£¬µ«ÔÚÉÏÊö±àÒëÆ÷ĬÈÏÉèÖÃÏ£¬Ê¹ÓÃsizeof¼ÆËã³öµÄ½á¹¹ÌåÀàÐÍ´óСΪ8¸ö×Ö½Ú£¬ÒòΪ±àÒëÆ÷ÔڸýṹµÄµÚÒ»¸ö³ÉÔ±ºóÌîÈëÁË3¸ö×Ö½ÚÀ´±£³Ö³ÉÔ±µÄ¶ÔÆë¡£ÕâÑù£¬ÔÚÐòÁл¯×Ö½ÚÁ÷µÄʱºò¾Í²úÉúÁËÎÊÌ⣬¸Ã½á¹¹ÀàÐ͵ıäÁ¿Ö¸ÕëÖ±½Óת»¯³Échar *»òÕßʹÓÃmemcpyµÃ³öµÄ×Ö½ÚÁ÷¼´Îª8¸ö×Ö½Ú¶ø·Ç5¸ö×Ö½Ú¡£Ò»°ãÇé¿öÏ£¬´«Êä¹æÔ¼Ö»¶¨ÒåÓÐЧ×Ö½Ú£¬Òò¶øÉÏÊö·½Ê½²úÉúµÄ×Ö½ÚÁ÷ÖÐ3¸ö×Ö½Ú½«²»ÔÚ¹æÔ¼Öж¨Ò壬Òò´ËÔ¶³ÌÖ÷»úÔÚ½âÎöµÄʱºò»á²úÉúÎó½â£¬µ±È»³ý·ÇÔ¶³Ì½âÎö³ÌÐò²ÉÓÃͬÑùµÄÐòÁл¯·½Ê½ºÍͬÑùµÄ½á¹¹¶ÔÆëÉèÖ㬶øÕâÔÚijЩÇé¿öÏÂÄÑÒÔ±£Ö¤¡£ËùÒÔ£¬ÔڽṹµÄÐòÁл¯¹ý³ÌÖУ¬±ØÐë½ö´¦ÀíÓÐЧ×Ö½Ú£¬Ê¹µÃ×Ö½ÚÁ÷·ûºÏ¹æÔ¼¶¨Òå¡£
    ¶àÓà×ֽڵIJúÉúÔ­ÒòÔÚÓÚ±àÒëÆ÷¶Ô½á¹¹Ìå³ÉÔ±¶ÔÆë×Ö½ÚÊýµÄÉèÖõIJ»Í¬£¬VCºÍGCC(MinGW)µÄĬÈÏÉèÖÃΪ8×Ö½Ú¶ÔÆ룬ËùÒÔÐèÒª¸Ä±äÆäĬÈϵĶÔÆë×Ö½ÚÊýΪ°´µ¥×Ö½Ú¶ÔÆ룬¼´¿ÉÒÔ½â¾öÉÏÊöÎÊÌâ¡£¾ßÌå·½·¨ÊÇÔÚ´úÂëÍ·ÖмÓÈë: 
   #pragma pack(1)¼´¿É¡£
   ´ËºóʹÓÃsizeof¼ÆËã³öµÄ½á¹¹Ìå´óС¼´Îª¸÷³ÉÔ±´óСµÄ×ܺ͡£ÕâÔÚ°´¼È¶¨¹æÔ¼±àдÍøÂç¶þ½øÖÆÊý¾Ý´«Êä³ÌÐòʱÐèҪעÒâ¡£


Ïà¹ØÎĵµ£º

»ñÈ¡IPµÄC ´úÂë

»ñÈ¡IPµÄC ´úÂë #include<stdio.h> #include<winsock2.h> #pragma comment(lib,"ws2_32.lib") void CheckIP(void) //¶¨ÒåCheckIP£¨£©º¯Êý£¬ÓÃÓÚ»ñÈ¡±¾»úIPµØÖ· { WSADATA wsaData; char name[255]; //¶¨ÒåÓà ...
»ñÈ¡IPµÄC ´úÂë
#include<stdio.h>
#include<winsock2.h>
#pragma comment(li ......

Ò»¸öC³ÌÐòµÄÄÚ´æ²¼¾Ö(memory layout)

Ò»¸öC³ÌÐòµÄÄÚ´æ²¼¾Ö(memory layout)
2009-09-09 15:19
Ò»¸öC³ÌÐòÒ»Ö±ÒÔÀ´¶¼ÊÇÓÉÒÔÏÂ5¸ö¶Î(pieces)×é³É£º
´úÂë¶Î(text segment)£º´æ·ÅCPUÖ´ÐеĻúÆ÷Ö¸Áî(machine instructions)¡£Í¨³£Çé¿öÏ£¬´úÂë¶ÎÊǿɹ²ÏíµÄ£¬Ê¹Æä¿É¹²ÏíµÄÄ¿µÄÊǶÔÓÚƵ·±±»Ö´ÐеijÌÐò£¬Ö»ÐèÒªÔÚÄÚ´æÖÐÓÐÒ»·Ý¿½±´¼´¿É£¬±ÈÈçÎı¾±à¼­Æ÷(text editors)£¬C ......

C/C++ ±ÊÊÔ¡¢ÃæÊÔÌâÄ¿´ó»ã×Ü

1.ÇóÏÂÃ溯ÊýµÄ·µ»ØÖµ£¨Î¢Èí£©
int func(x)
{
    int countx = 0;
    while(x)
    {
          countx ++;
          x = x&(x-1);
   &n ......

¼ûÖ¤C²ËÄñµÄ·ÉÏè

  ÏÖÔÚѧ±à³ÌÁË£¬×îÏÈѧµÄÊÇCÓïÑÔ£¬£¬Ï£Íû¾­¹ýŬÁ¦£¬×Ô¼ºÒ²ÄÜÏñÆäËûµÄÈËÒ»Ñù£¬³ÉΪһ¸öÓÅÐãµÄC³ÌÐòÔ±£¬£¬¾ÍÔÚCSDN£¬¼Ç¼ÏÂÎÒµÄC³ÌÐòÔ±³É³¤¹ý³Ì¡£
  Ìý±ðÈË˵£¬Ñ§ÓïÑÔ×îºÃµÄ;¾¶¾ÍÊǶàд´úÂ룬ϣÍûÎÒÔÚÕâÒ»·½ÃæÄÜ×öµÄ±È½ÏºÃ£¬»¹ÓоÍÊÇÅàÑøÁ¼ºÃµÄ±à³Ì·ç¸ñºÍÍŶӾ«Éñ¡£ÔÚCSDN£¬ÓкܶàµÄÁ¼Ê¦ÒæÓÑ£¬ÓÐËûÃÇ£¬ÏàÐÅÎÒÒ»¶ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ