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

C/C++ÓïÑÔʵÏÖ¶¯Ì¬Êý×é


CÊý×éµÄСÎÊÌâ
     ÕâÀï˵µÄ¶¯Ì¬Êý×éÊÇ¿ÉÒÔ¸ù¾ÝÐèÒª¶¯Ì¬Ôö³¤Õ¼ÓÃÄÚ´æµÄÊý×飬±ÈÈç³ÌÐò³õʼ·ÖÅäÁË100¸öÔªËØ£¬¿ÉÊÇÔËÐÐÁËÒ»¶Îʱ¼äºóÇøÇø100¸ö¿Õ¼ä²»ÄÜÂú×ãÁË£¬ÏÖÔÚÐèÒª400¸ö£¬Ôõô°ìÄØ£»Äǿ϶¨ÐèÒªÔÙ¶îÍâ·ÖÅä300¸ö¡£
     CÓïÑÔÓÐrealloc()º¯ÊýÀ´½â¾ö¿Õ¼äÀ©³äµÄÎÊÌ⣬µ«ÊDz»ÒªÍüÁËrealloc¿ÉÄÜ»áǨÒÆÄڴ棬ºÜ¶àʱºòÊý×éÖеÄÔªËػᱻÆäËüº¯Êý/Ä£¿éÒýÓã¬Èç¹ûµØÖ··¢ÉúÁ˱仯£¬½á¹û½«ÊÇÔÖÄÑÐԵġ£
     ÄÇôSTLµÄvectorÄØ£¿ËüÒ²ÓÐÏàͬµÄÎÊÌâ¡£
     Ò»´Î·ÖÅä×ã¹»µÄ¿Õ¼äÊÇ¿ÉÒÔ½â¾öÕâ¸öÎÊÌ⣬ºÜÃ÷ÏÔÕâ»áÔì³ÉÄÚ´æµÄÀË·Ñ£¬Õâ¸ö×ö·¨²»ËãÃ÷ÖÇ¡£
     ²»Ê¹ÓÃÊý×éÄØ£¿Ê¹ÓÃlistÄܽâ¾öÒ»²¿·ÖÎÊÌ⣬µ«ÊÇlist²»ÄÜÖ§³ÖËæ»ú·ÃÎÊ°¡£¬¼øÓÚЧÂÊÉϵÄÓ²ÉË£¬ÏÔÈ»²»ÄÜËæ±ãÓÃlistÌæ»»Êý×é¡£
     Ôõô½â¾öÕâ¸öÎÊÌâÄØ£¿¶¯Ì¬Êý×飡ÔÚHPServer µÄDemutex Table¾ÍÓõ½Á˶¯Ì¬Êý×飬ÊÂʵ֤Ã÷Ч¹û²»´í¡£
¶¯Ì¬Êý×éµÄÌØÕ÷
¶¯Ì¬Êý×éÊÇÒ»¸öºÜ¼òµ¥Ò×ÓõÄÊý¾Ý½á¹¹£¬µ«ÊǼòµ¥²»´ú±íÓŵãС£¬ËüµÄÌØÕ÷ÈçÏ£º
1 ¸ù¾ÝÐèÒª¶¯Ì¬ÅúÁ¿Ôö³¤Äڴ棻
2 Ò»¾­·ÖÅ䣬ԪËصØÖ·²»»áÔٴα仯£»
3 ʵÏÖ¼òµ¥£¬Ð§Âʸߣ¬ÊÂʵÉÏËüºÍÆÕͨÊý×éÏà±È»ù±¾Ã»ÓÐЧÂÊËðʧ£»
4 ×î´ó¸öÊý¹Ì¶¨£» 
Æäʵ×îÖØÒªµÄ¾ÍÊÇÌØÕ÷2ÁË£¬²»È»Ö±½ÓʹÓÃrealloc¶à·½±ãÄØ£¬µ±È»¶¯Ì¬Êý×éµÄʵÏÖÒ²ºÜ·½±ã£¬ÏÂÃæ¾Í»áÏêϸ˵˵¡£
ÌØÕ÷4ʵ¼ÊÉÏÊǸöÏÞÖÆ£¬µ«ÊÇÏàÐÅÎÒ£¬ÄãµÄ³ÌÐò²»¿ÉÄÜ´ïµ½Õâ¸ö×î´óÖµ¡£
¶¯Ì¬Êý×éµÄʵÏÖ
ÈçÉÏÃæËù˵µÄ£¬¶¯Ì¬Êý×éʵÏÖÆðÀ´ºÜ¼òµ¥£¬ÒÔ϶¼¼ÙÉèÊý×éÔªËØÀàÐÍÊÇT£¬Ê×ÏÈÐèÒªÒ»¸ö¸¨ÖúÊý¾Ý½á¹¹¡£
view plaincopy to clipboardprint?
struct ARRAY_ELE_S  
{  
    T item_array[1024];  
};  
ARRAY_ELE_S *pArray[2000];  
int iSize;   
±äÁ¿pArrayÊÇÒ»¸öARRAY_ELE_SÀàÐ͵ÄÖ¸ÕëÊý×飬Õâ¸öÒ²¾ÍÊÇÄãµÄ¶¯Ì¬Êý×éÁË£»iSize¼Ç¼Á˵±Ç°Êý×éµÄ´óС¡£
ÉÏÃæµÄ´úÂë±íÃ÷£º
1 Êý×éÿ´Î¶¯Ì¬Ôö³¤1024¸öÔªËØ£»
2 Êý×éµÄ×î´óÔªËظöÊý¿ÉÒÔµ½£º2000*1024¸ö£¬Èç¹ûÕâ¸ö»¹²»¹»£¬Äã¿ÉÒÔ°ÑÕâ¸öÖµ¸ÄµÄ¸ü´óµã¡£
ÏÈÀ´¿´¿´ÄÚ´æÕ¼Óã¬pArray±¾ÉíÕ¼ÓÃ2000*4£¬´óÔ¼ÊÇ8KµÄÄڴ棬»ù±¾¿ÉÒÔºöÂÔÁË¡£
Èç¹ûÒ»´Î·ÖÅäÒ»¸ö2000*1024µÄÊý×éarray[2000*1024]£¬ÄÇôһ´Î¾ÍÒª·ÖÅäµÄÄÚ´æÊÇ£º2*sizeof


Ïà¹ØÎĵµ£º

C ÖÐ extern ºÍ static

CÓïÑÔÖУº
extern £ºextern£¨ÍⲿÒýÓã©¿ÉÒÔÖÃÓÚ±äÁ¿»òÕߺ¯ÊýÇ°£¬ÒÔ±êʾ±äÁ¿»òº¯ÊýµÄ¶¨ÒåÔÚ±ðµÄÎļþÖУ¬ÔÚÒ»¸öÎļþÖÐÓõ½µÄexternÕâЩ±äÁ¿»òº¯ÊýÊÇÍâÀ´µÄ£¬²»ÊDZ¾Îļþ¶¨ÒåµÄ£¬Ìáʾ±àÒëÆ÷Óöµ½´Ë±äÁ¿ºÍº¯ÊýʱÔÚÆäËûÄ£¿éÖÐÑ°ÕÒÆ䶨Òå¡£×¢Ò⣬ֻÓÐÆäËûÎļþÖеÄÈ«¾Ö±äÁ¿²ÅÄܱ»ÆäËûÎļþËùextern¡£
extern int val;
×¢£º
  ......

C/C++³ÌÐòÄÚ´æ·ÖÅäÏê½â


Ò»¸öÓÉC/C++±àÒëµÄ³ÌÐòÕ¼ÓõÄÄÚ´æ·ÖΪÒÔϼ¸¸ö²¿·Ö
1¡¢Õ»Çø£¨stack£©— ³ÌÐòÔËÐÐʱÓɱàÒëÆ÷×Ô¶¯·ÖÅ䣬´æ·Åº¯ÊýµÄ²ÎÊýÖµ£¬¾Ö²¿±äÁ¿µÄÖµµÈ¡£Æä²Ù×÷·½Ê½ÀàËÆÓÚÊý¾Ý½á¹¹ÖеÄÕ»¡£³ÌÐò½áÊøʱÓɱàÒëÆ÷×Ô¶¯ÊÍ·Å¡£
2¡¢¶ÑÇø£¨heap£© — ÔÚÄڴ濪±ÙÁíÒ»¿é´æ´¢ÇøÓò¡£Ò»°ãÓɳÌÐòÔ±·ÖÅäÊÍ·Å£¬ Èô³ÌÐòÔ±²»ÊÍ·Å£¬³ÌÐò½áÊøʱ¿É ......

GCC ÐÂÊÖ c/c++

±¾ÎÄÊÇд¸ø gcc ÐÂÊÖµÄÈëÃÅÎÄÕ£¬ËùÒÔÄÚÈݱȽϼòµ¥¡£Èç¹ûÄãÖªµÀÏÂÃæ3ÌõÃüÁ¿ÉÒÔ±àÒëc++µÄ»°£¬¾Í²»ÓÃÔÚ±¾ÎÄÀË·Ñʱ¼äÁË
´úÂë:
g++ -Wall hellocpp.cpp
gcc -Wall hellocpp.cpp -lstdc++
gfortran -Wall hellocpp.cpp -lstdc++
×¢£º±¾ÎÄ×îаæÔÚwikiÖÐ http://wiki.ubuntu.org.cn/Gcchowto
£¨½¨Òé´ó¼ÒÖ±½Ó·ÃÎÊwikiÖ ......

C unsigned int and int

Ê×ÏȽøÐÐÒ»¸öʵÑ飬·Ö±ð¶¨ÒåÒ»¸ösigned intÐÍÊý¾ÝºÍunsigned intÐÍÊý¾Ý£¬È»ºó½øÐдóС±È½Ï£º
unsigned int a=20;
signed int b=-130;
a>b?»¹ÊÇb>a£¿ÊµÑéÖ¤Ã÷b>a£¬Ò²¾ÍÊÇ˵£­130>20,Ϊʲô»á³öÏÖÕâÑùµÄ½á¹ûÄØ£¿
ÕâÊÇÒòΪÔÚCÓïÑÔ²Ù×÷ÖУ¬Èç¹ûÓöµ½ÎÞ·ûºÅÊýÓëÓзûºÅÊýÖ®¼äµÄ²Ù×÷£¬±àÒëÆ÷»á×Ô¶¯×ª»¯ÎªÎÞ·ûºÅ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ