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[
Ïà¹ØÎĵµ£º
½ñÌìÊÇ5ÔµÄ×îºóÒ»ÌìÁË£¬2010ÄêµÄ5Ô£¬µ¹Ã¹µÄÒ»¸öÔÂÖÕÓÚÒª¹ýÈ¥ÁË¡£½ñÌì³é¿ÕÎÒÓÖ¶ÁÍêÁ˵ÚÈýÕ£¬Ë³±ã×öϱʼǡ£
ÕâÒ»ÕµÄÌâÄ¿½Ð×ö---ÓïÒå“ÏÝÚå”
³ÌÐòÒ²ÓпÉÄܱíÃæ¿´ÉÏÈ¥ÊÇÒ»¸öÒâ˼£¬Êµ¼ÊÉϵÄÒâ˼ȴÏàÈ¥ÉõÔ¶¡£
¶ÔÓÚÊý×飺
CÓïÑÔÖÐÖ»ÓÐһάÊý×飬 ......
1) goto
goto Ö»ÄÜÔÚÒ»¸öº¯ÊýÄÚÌøת¡£½¨ÒéÉÙÓã¬Ê¹µÃ³ÌÐòά»¤ÆðÀ´ÈÝÒ׳ö´í£»µ«ÊÇ£¬ÔÚÓжà¸öÑ»·Çé¿öÏÂÌøת£¬ÓÐʱÓÃgoto¿ÉÒÔʹµÃÎÊÌâ±äµÃ¼òµ¥¡£
class A
{
public:
A(){}
~A(){}
};
&nbs ......
°ÑÊäÈëµÄÒ»´®×Ö·ûת³ÉÊý×飬ת³ÉÁ´±í£¬È»ºóɾȥÆäÖÐÖ¸¶¨µÄ×Ö·û£¬ÔÚβ²¿Ìí¼ÓÒ»¸ö×Ö·û¡£
£¨³ÌÐò»¹²»ÍêÉÆ£¬Ã»ÓжÔÊä´íµÄÇé¿ö½øÐд¦Àí£¬£¬ÔÝʱÏÈÕâÑù°É¡£¡£= =¡££©
#include<stdio.h>
#include<malloc.h>
#define LEN sizeof(struct link)
struct link
{
char ch;
struct link *next;
}*string;
char a ......
̽Ë÷еÄC + +ºÍMFCÔÚVisual Studio 2010¹¦ÄÜ
Sumit Kumar
2010ÄêÁгöµÄVisual Studio C + +¿ª·¢µÄ¾Þ´óºÃ´¦¡£´Ó¹ÍÓÃÄÜÁ¦ÌṩÓÉWindows 7´óÁ¿´úÂëµÄ»ù´¡¹¤×÷£¬ÒÔÔöÇ¿Éú²úÁ¦ÌØÕ÷µÄÐÂÌص㣬ÓÐһЩеĶ«Î÷£¬Ìá¸ßÁ˼¸ºõËùÓеÄC + +¿ª·¢ÈËÔ±¡£
ÔÚÕâƪÎÄÕÂÖУ¬ÎÒ½«½âÊÍ΢ÈíÒѾ½â¾öÁËÈçºÎÓÃC + +¿ª·¢ÈËÔ±ËùÃæÁٵĹ㷺µÄһЩÎÊÌ ......