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

c/c++ ÄÚ´æ¶ÔÆë sizeof

   һƪ½²¶ÔÆë±È½ÏºÃµÄÎÄÕ£¬×ªÌùÈçÏÂ:
´óÖ±ê×¢Ò»¶þ:
1.ÄÚ´æ¶ÔÆë:¼ÆËã»úϵͳ¶Ô»ù±¾ÀàÐÍÊý¾ÝÔÚÄÚ´æÖдæ·ÅµÄλÖÃÓÐÏÞÖÆ£¬ËüÃÇ»áÒªÇóÕâЩÊý¾ÝµÄÊ×µØÖ·µÄÖµÊÇij¸öÊýk(ͨ³£ËüΪ4»ò8)µÄ±¶ÊýkÔò±»³ÆΪ¸ÃÊý¾ÝÀàÐ͵ĶÔÆëÄ£Êý(alignment modulus)
2.²»Í¬±àÒëÆ÷ĬÈϵÄ×î´ó¶ÔÆë×Ö½ÚÊýÊDz»Ò»ÑùµÄ,±ÈÈçvc==8,gcc==4,¿ÉÒÔͨ¹ý#progma pack (n)À´ÐÞ¸Ä,·ÖÎö³ÌÐòµÄʱºòҪעÒâ±àÒëÆ÷µÄÇø±ð
3.Ò»¸ö½á¹¹ÌåÀïÃæ,°´ÕÕalignment modulus×î´óµÄÊý¾Ý³ÉÔ±À´½øÐжÔÆë,³¬¹ý±àÒëÆ÷¹æ¶¨×î´óµÄ¶ÔÆë×Ö½Ú¸öÊý,°´±àÒëÆ÷×î´ó¶ÔÆë×Ö½Ú¸öÀ´
4.doubleÀàÐÍÔÚvcÀïÃæalignment modulus == 8,¶øÔÚgccÀïÃæÓÉÓÚĬÈÏ×î´ó¶ÔÆë¸öÊýÊÇ4,²»ÉèÖõĻ°,alignment modulus == 4
5.ÒòΪÊý×é¸÷ÔªËØÖ®¼ä²»ÄÜÓпÕ϶,ËùÒÔ{int a;char b;}
ÕâÖÖÇé¿ö,ĬÈÏÔÚVCÀïÃæÒ²ÐèÒªÕ¼8¸ö×Ö½Ú.
   ÕýÎÄÈçÏ£º
   µ±ÔÚCÖж¨ÒåÁËÒ»¸ö½á¹¹ÀàÐÍʱ£¬ËüµÄ´óСÊÇ·ñµÈÓÚ¸÷×Ö¶Î(field)´óС֮ºÍ£¿±àÒëÆ÷½«ÈçºÎÔÚÄÚ´æÖзÅÖÃÕâЩ×ֶΣ¿ANSI C¶Ô½á¹¹ÌåµÄÄÚ´æ²¼¾ÖÓÐʲôҪÇ󣿶øÎÒÃǵijÌÐòÓÖÄÜ·ñÒÀÀµÕâÖÖ²¼¾Ö£¿ÕâЩÎÊÌâ»òÐí¶Ô²»ÉÙÅóÓÑÀ´Ëµ»¹ÓеãÄ£ºý£¬ÄÇô±¾ÎľÍÊÔ×Å̽¾¿ËüÃDZ³ºóµÄÃØÃÜ¡£
    Ê×ÏÈ£¬ÖÁÉÙÓÐÒ»µã¿ÉÒԿ϶¨£¬ÄǾÍÊÇANSI C±£Ö¤½á¹¹ÌåÖи÷×Ö¶ÎÔÚÄÚ´æÖгöÏÖµÄλÖÃÊÇËæËüÃǵÄÉùÃ÷˳ÐòÒÀ´ÎµÝÔöµÄ£¬²¢ÇÒµÚÒ»¸ö×ֶεÄÊ×µØÖ·µÈÓÚÕû¸ö½á¹¹ÌåʵÀýµÄÊ×µØÖ·¡£±ÈÈçÓÐÕâÑùÒ»¸ö½á¹¹Ì壺
 
  struct vector{int x,y,z;} s;
  int *p,*q,*r;
  struct vector *ps;
 
  p = &s.x;
  q = &s.y;
  r = &s.z;
  ps = &s;
  assert(p < q);
  assert(p < r);
  assert(q < r);
  assert((int*)ps == p);
  // ÉÏÊö¶ÏÑÔÒ»¶¨²»»áʧ°Ü
    Õâʱ£¬ÓÐÅóÓÑ¿ÉÄÜ»áÎÊ:"±ê×¼ÊÇ·ñ¹æ¶¨ÏàÁÚ×Ö¶ÎÔÚÄÚ´æÖÐÒ²ÏàÁÚ?"¡£ ßí£¬¶Ô²»Æð£¬ANSI CûÓÐ×ö³ö±£Ö¤£¬ÄãµÄ³ÌÐòÔÚÈκÎʱºò¶¼²»Ó¦¸ÃÒÀÀµÕâ¸ö¼ÙÉè¡£ÄÇÕâÊÇ·ñÒâζ×ÅÎÒÃÇÓÀÔ¶ÎÞ·¨¹´ÀÕ³öÒ»·ù¸üÇåÎú¸ü¾«È·µÄ½á¹¹ÌåÄÚ´æ²¼¾Öͼ£¿Å¶£¬µ±È»²»ÊÇ¡£²»¹ýÏÈÈÃÎÒÃÇ´ÓÕâ¸öÎÊÌâÖÐÔÝʱ³éÉí£¬¹Ø×¢Ò»ÏÂÁíÒ»¸öÖØÒªÎÊÌâ————ÄÚ´æ¶ÔÆë¡£
    Ðí¶àʵ¼ÊµÄ¼ÆËã»úϵͳ¶Ô»ù±¾ÀàÐÍÊý¾ÝÔÚÄÚ´æÖдæ·ÅµÄλÖÃÓÐÏÞÖÆ£¬ËüÃÇ»áÒªÇóÕâЩÊý¾ÝµÄÊ×µØÖ·µÄÖµÊÇij¸öÊýk(ͨ³£ËüΪ4»ò8)µÄ±¶Êý£¬Õâ¾ÍÊÇËùνµÄÄÚ´æ¶ÔÆ룬¶øÕâ¸ökÔò±»³


Ïà¹ØÎĵµ£º

C/C++λ²Ù×÷

C/C++λ²Ù×÷
Ò»¡¢´«Í³µÄC·½Ê½Î»²Ù×÷£º
1.»ù±¾²Ù×÷£º
  ʹÓÃÒ»¸öunsigned int±äÁ¿À´×÷ΪλÈÝÆ÷¡£
2.²Ù×÷·û£º
|  °´Î»»ò²Ù×÷·û£ºresult=exp1|exp2;µ±exp1ºÍexp2ÖжÔӦλÖÐÖÁÉÙÓÐÒ»¸öΪ1ʱ£¬resultÖжÔӦλΪ1£¬·ñÔòΪ0¡£
&  °´Î»Óë²Ù×÷·û£º£ºresult=exp1&exp2;µ±exp1ºÍexp2ÖжÔӦλȫΪ1ʱ ......

C Traps and Pitfalls ¶ÁÊéÕª¼Ç

Óõ¥ÒýºÅÒýÆðµÄÒ»¸ö×Ö·ûʵ¼ÊÉÏ´ú±íÒ»¸öÕûÊý£¬ÕûÊýÖµ¶ÔÓ¦ÓÚ¸Ä×Ö·ûÔÚ±àÒëÆ÷²ÉÓõÄ×Ö·û¼¯ÖеÄÐòÁÐÖµ¡£
ÓÃË«ÒýºÅÒýÆðµÄ×Ö·û´®£¬´ú±íµÄÊÇÒ»¸öÖ¸ÏòÎÞÃûÊý×éÆðʼ×Ö·ûµÄÖ¸Õ룬¸ÃÊý×鱻˫ÒýºÅÖ®¼äµÄ×Ö·ûÒÔ¼°Ò»¸ö¶îÍâµÄ¶þ½øÖÆֵΪÁãµÄ×Ö·û'\0'³õʼ»¯¡£
printf("Hello world\n");
Óë
char hello[] = {'H', 'e', 'l', 'l', 'o', ' ' ......

µÝ¹é »ØËÝ·¨Çó½â8»ÊºóÎÊÌ⣨C£©

ÎÞÒâÖз­³öÁËNÄêǰдµÄµÝ¹é-»ØËÝ·¨Çó½â8»ÊºóÎÊÌ⣬¸É´âÈûµ½²©¿ÍÖаɡ£
#include <stdio.h>
#include <conio.h>
#include <math.h>
#define QUEENS 8
// ¼Ç¼½âµÄÐòºÅµÄÈ«¾Ö±äÁ¿¡£
int iCount = 0;
// ¼Ç¼»ÊºóÔÚ¸÷ÁÐÉϵķÅÖÃλÖõÄÈ«¾ÖÊý×é¡£
int Site[QUEENS];
// µÝ¹éÇó½âµÄº¯Êý¡£
void Q ......

ÈçºÎʹÓÃObjective C½âÎöHTMLºÍXML

ʹÓÃObjective-C½âÎöHTML»òÕßXML£¬ÏµÍ³×Ô´øÓÐÁ½ÖÖ·½Ê½Ò»¸öÊÇͨ¹ýlibxml£¬Ò»¸öÊÇͨ¹ýNSXMLParser¡£²»¹ýÕâÁ½ÖÖ·½Ê½¶¼ÐèÒª×Ô¼ºÐ´ºÜ¶à±àÂëÀ´´¦ÀíץȡÏÂÀ´µÄÄÚÈÝ£¬¶øÇÒ²»ÊǺÜÖ±¹Û¡£
ÓÐÒ»¸ö±È½ÏºÃµÄÀà¿âhpple£¬ËüÊÇÒ»¸öÇáÁ¿¼¶µÄ°ü×°¿ò¼Ü£¬¿ÉÒԺܺõĽâ¾öÕâ¸öÎÊÌâ¡£ËüÊÇÓÃXPathÀ´¶¨Î»ºÍ½âÎöHTML»òÕßXML¡£
°²×°²½Ö裺
-¼ÓÈë libx ......

CÖÐÈçºÎµ÷ÓÃC++£¿C++ÖÐÈçºÎµ÷ÓÃC

CÖÐÈçºÎµ÷ÓÃC++£¿C++ÖÐÈçºÎµ÷ÓÃC?Õâ¸öÎÊÌâÊÇÐí¶àÈí¼þ¹«Ë¾ÃæÊÔ¹ý³ÌÖлáÎʵ½µÄÒ»¸ö³£¼ûÎÊÌâ¡£»Ø´ðÕâ¸öÎÊÌâ²¢²»À§ÄÑ£¬ÄǾÍÊÇʹÓÃ
extern "C",µ«ÊÇÃæÊÔ¹Ù¿ÉÄÜÏëͨ¹ýÕâ¸öÎÊÌâÁ˽âÄã¶ÔC/C++ÕÆÎյij̶ȡ£ÏÂÃæ×Ðϸ·ÖÎö¸ÃÎÊÌâ¡£
    Ê×ÏÈ£¬×÷
ΪexternÊÇC/C++ÓïÑÔÖбíÃ÷º¯ÊýºÍÈ«¾Ö±äÁ¿×÷Ó÷¶Î§£¨¿ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ