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

C/C++·µ»ØÄÚ²¿¾²Ì¬³ÉÔ±µÄÏÝÚå

 C/C++·µ»ØÄÚ²¿¾²Ì¬³ÉÔ±µÄÏÝÚå
³Âð©
±³¾°
ÔÚÎÒÃÇÓÃ
C/C++¿ª·¢µÄ¹ý³ÌÖУ¬×ÜÊÇÓÐÒ»¸öÎÊÌâ»á¸øÎÒÃÇ´øÀ´¿àÄÕ¡£Õâ¸öÎÊÌâ¾ÍÊǺ¯ÊýÄںͺ¯ÊýÍâ´úÂëÐèҪͨ¹ýÒ»¿éÄÚ´æÀ´½»»¥£¨±ÈÈ磬º¯Êý·µ»Ø×Ö·û´®£©£¬Õâ¸öÎÊÌâÀ§
Èźͺܶ࿪·¢ÈËÔ±¡£Èç¹ûÄãµÄÄÚ´æÊÇÔÚº¯ÊýÄÚÕ»ÉÏ·ÖÅäµÄ£¬ÄÇôÕâ¸öÄÚ´æ»áËæן¯ÊýµÄ·µ»Ø¶ø±»µ¯Õ»ÊÍ·Å£¬ËùÒÔ£¬ÄãÒ»¶¨Òª·µ»ØÒ»¿éº¯ÊýÍⲿ»¹ÓÐЧµÄÄÚ´æ¡£
ÕâÊÇÒ»¸öÈÃÎÞÊýÈËÀ§ÈŵÄÎÊÌâ¡£Èç¹ûÄãÒ»²»Ð¡ÐÄ£¬Äã¾ÍºÜÓпÉÄÜÔÚÕâ¸öÉÏÃæ·¸´íÎó¡£µ±È»Ä¿Ç°Óкܶà½â¾ö·½·¨£¬Èç¹ûÄãÊìϤһЩ±ê×¼¿âµÄ»°£¬Äã¿ÉÒÔ¿´µ½Ðí¶à¸÷ʽ¸÷ÑùµÄ½â¾ö·½·¨¡£´óÌåÀ´ËµÓÐÏÂÃ漸ÖÖ£º
1£©
ÔÚº¯ÊýÄÚ²¿Í¨¹ýmalloc»ònewÔÚ¶ÑÉÏ·ÖÅäÄڴ棬Ȼºó°ÑÕâ¿éÄÚ´æ·µ»Ø£¨ÒòΪÔÚ¶ÑÉÏ·ÖÅäµÄÄÚ´æÊÇÈ«¾Ö¿É¼ûµÄ£©¡£ÕâÑù´øÀ´µÄÎÊÌâ¾ÍÊÇDZÔÚµÄÄÚ´æÎÊÌâ¡£Òò
Ϊ£¬Èç¹û·µ»Ø³öÈ¥µÄÄÚ´æ²»ÊÍ·Å£¬ÄÇô¾ÍÊÇmemory
Leak¡£»òÕßÊDZ»¶à´ÎÊÍ·Å£¬´Ó¶øÔì³É³ÌÐòµÄcrash¡£ÕâÁ½¸öÎÊÌⶼÏ൱µÄÑÏÖØ£¬ËùÒÔÕâÖÖÉè¼Æ·½·¨²¢²»ÍƼö¡££¨ÔÚһЩWindows
APIÖУ¬µ±Äãµ÷ÓÃÁËһЩAPIºó£¬Äã±ØÐèÒ²Òªµ÷ÓÃËûµÄijЩAPIÀ´ÊÍ·ÅÕâ¿éÄڴ棩
2£©ÈÃÓû§´«ÈëÒ»¿éËû×Ô¼ºµÄÄÚ´æµØÖ·£¬¶øÔÚº¯ÊýÖаÑÒª
·µ»ØµÄÄÚ´æ·Åµ½Õâ¿éÄÚ´æÖС£ÕâÊÇÒ»¸öÄ¿Ç°ÆÕ±éʹÓõķ½Ê½¡£ºÜ¶àWindows
APIº¯Êý»òÊDZê×¼Cº¯Êý¶¼ÐèÒªÄã´«ÈëÒ»¸öbufferºÍÕâ¸öbufferµÄ³¤¶È¡£ÕâÖÖ·½Ê½¶ÔÎÒÃÇÀ´ËµÓ¦¸ÃÊÇÂżû²»ÏÊÁË¡£ÕâÖÖ·½Ê½µÄºÃ´¦¾ÍÊÇÓɺ¯ÊýÍⲿµÄ
³ÌÐòÀ´Î¬»¤Õâ¿éÄڴ棬±È½Ï¼òÏÔÖ±¹Û¡£µ«ÎÊÌâ¾ÍÊÇÔÚʹÓÃÉÏÉÔÐíÓÐЩÂé·³¡£²»¹ýÕâÖÖ·½Ê½°Ñ·¸´íÎóµÄ»úÂʼõµ½ÁË×îµÍ¡£
3£©µÚÈýÖÖ·½Ê½ÏԵñȽÏÁí
À࣬ËûÀûÓÃÁËstaticµÄÌØÐÔ£¬staticµÄÕ»ÄÚ´æÒ»µ©·ÖÅ䣬ÄÇÕâ¿éÄÚ´æ²»»áËæן¯ÊýµÄ·µ»Ø¶øÊÍ·Å£¬¶øÇÒ£¬ËüÊÇÈ«¾Ö¿É¼ûµÄ£¨Ö»ÒªÄãÓÐÕâ¿éÄÚ´æµÄµØ
Ö·£©¡£ËùÒÔ£¬ÓÐһЩº¯ÊýʹÓÃÁËstaticµÄÕâ¸öÌØÐÔ£¬¼´²»ÓÃʹÓöÑÉϵÄÄڴ棬Ҳ²»ÐèÒªÓû§´«ÈëÒ»¸öbufferºÍÆ䳤¶È¡£´Ó¶ø£¬Ê¹ÓõÃ×Ô¼ºµÄº¯Êý³¤µÃºÜ
ƯÁÁ£¬Ò²ºÜÈÝÒ×ʹÓá£
ÕâÀÎÒÏë¶ÔµÚÈý¸ö·½·¨½øÐÐһЩÌÖÂÛ¡£Ê¹ÓÃstaticÄÚ´æÕâ¸ö·½·¨¿´ËƲ»´í£¬µ«ÊÇËüÓÐÈÃÄãÏëÏó²»µ½µÄÏÝÚå¡£ÈÃÎÒÃÇÀ´ÓÃÒ»¸öʵ¼Ê·¢ÉúµÄ°¸ÀýÀ´¾ÙÒ»¸öÀý×Ó°É¡£
ʾÀý
Óйýsocket±à³Ì¾­ÑéµÄÈËÒ»¶¨ÖªµÀÒ»¸öº¯Êý½Ð£ºinet_ntoa£¬Õâ¸öº¯ÊýÖ÷ÒªµÄ¹¦ÄÜÊÇ°ÑÒ»¸öÊý×ÖÐ͵ÄIPµØַת³É×Ö·û´®£¬Õâ¸öº¯ÊýµÄ¶¨ÒåÊÇÕâÑùµÄ£¨×¢ÒâËüµÄ·µ»ØÖµ£©£º
char *inet_ntoa(struct in_addr in);
ÏÔÈ»£¬Õâ¸öº¯Êý²»»á·ÖÅä¶ÑÉϵÄÄڴ棬¶øËûÓÖûÓÐÈÃÄã´«Ò»ÏÂ×Ö·û´®µÄbuffer½øÈ룬ÄÇ
ôËûÒ»¶¨Ê¹ÓÓ·µ»Østatic
char[


Ïà¹ØÎĵµ£º

CÒÅÁôµÄ½á¹¹Ìøת ±±º£

1)          goto
goto Ö»ÄÜÔÚÒ»¸öº¯ÊýÄÚÌøת¡£½¨ÒéÉÙÓã¬Ê¹µÃ³ÌÐòά»¤ÆðÀ´ÈÝÒ׳ö´í£»µ«ÊÇ£¬ÔÚÓжà¸öÑ­»·Çé¿öÏÂÌøת£¬ÓÐʱÓÃgoto¿ÉÒÔʹµÃÎÊÌâ±äµÃ¼òµ¥¡£
class A
{
public:
A(){}
~A(){}
};
           &nbs ......

C' Fragment

°ÑÊäÈëµÄÒ»´®×Ö·ûת³ÉÊý×飬ת³ÉÁ´±í£¬È»ºóɾȥÆäÖÐÖ¸¶¨µÄ×Ö·û£¬ÔÚβ²¿Ìí¼ÓÒ»¸ö×Ö·û¡£
£¨³ÌÐò»¹²»ÍêÉÆ£¬Ã»ÓжÔÊä´íµÄÇé¿ö½øÐд¦Àí£¬£¬ÔÝʱÏÈÕâÑù°É¡£¡£= =¡££©
#include<stdio.h>
#include<malloc.h>
#define LEN sizeof(struct link)
struct link
{
char ch;
struct link *next;
}*string;
char a ......

linux³£ÓÃcÍ·Îļþ

linux³£ÓÃÍ·ÎļþÈçÏ£º
POSIX±ê×¼¶¨ÒåµÄÍ·Îļþ
<dirent.h>       
Ŀ¼Ïî
<fcntl.h>         Îļþ¿ØÖÆ
<fnmatch.h>    ÎļþÃûÆ¥ÅäÀàÐÍ
<glob.h>   
·¾¶ÃûģʽƥÅäÀàÐÍ
< ......

CÖÐexternÐÞÊηûµÄÓ÷¨

ÔÚCÓïÑÔÖУ¬ÐÞÊηûexternÓÃÔÚ±äÁ¿»òÕߺ¯ÊýµÄÉùÃ÷Ç°£¬ÓÃÀ´ËµÃ÷“´Ë±äÁ¿/º¯ÊýÊÇÔڱ𴦶¨ÒåµÄ£¬ÒªÔÚ´Ë´¦ÒýÓÔ¡£
Ò».externÐÞÊαäÁ¿µÄÉùÃ÷
¾ÙÀýÀ´Ëµ£¬Èç¹ûÎļþa.cÐèÒªÒýÓÃb.cÖбäÁ¿int v£¬¾Í¿ÉÒÔÔÚa.cÖÐÉùÃ÷extern int v£¬È»ºó¾Í¿ÉÒÔÒýÓñäÁ¿v¡£ÕâÀïÐèҪעÒâµÄÊÇ£¬±»ÒýÓõıäÁ¿vµÄÁ´½ÓÊôÐÔ±ØÐëÊÇÍâÁ´½Ó£¨external£ ......

20100601 cÏÝÚåÓëÖ¸Õë¶ÁÊé±Ê¼Ç£¨µÚËÄÎåÁùÕ£©

  ÕâÈýÕÂÖ÷Òª½²ÁËCÓïÑÔµÄÁ´½Ó¡¢¿âº¯Êý¡¢Ô¤´¦Àí¡£»¹ÊÇÓеã»ÞɬÄѶ®°¡¡£
  Ò»¸öC³ÌÐòÊÇ¿ÉÒÔÓжà¸ö²¿·Ö×é³ÉµÄ£¬µ«ÊDZàÒëÆ÷ÿ´ÎÖ»ÄܱàÒëÒ»¸öÎļþ£¬ÕÒ³öÆäÖеĴíÎó¡£Ä³Ð©CÓïÑÔʵÏÖÌṩÁËÒ»¸ö³ÆΪlintµÄ³ÌÐò£¬¿ÉÒÔ²¶»ñ´óÁ¿µÄ´ËÀà´íÎó¡£Á¬½ÓÆ÷Ò»°ãÊÇÓë±àÒëÆ÷·ÖÀëµÄ£¬±àÒëÆ÷ÊÇ°ÑC³ÌÐò“·­Ò딳ɶÔÁ¬ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ