C/C++ÓïÑÔ±à³ÌÐÞÑø2
21¡¢gotoÓï¾äµÄʹÓÃ
—————————
NÄêÇ°£¬Èí¼þ¿ª·¢µÄÒ»´ú×Úʦ——µÏ½Ü˹ÌØÀ(Dijkstra)˵¹ý£º“goto statment is
harmful !!”£¬²¢½¨ÒéÈ¡ÏûgotoÓï¾ä¡£ÒòΪgotoÓï¾ä²»ÀûÓÚ³ÌÐò´úÂëµÄά»¤ÐÔ¡£
ÕâÀïÎÒҲǿÁÒ½¨Ò鲻ҪʹÓÃgotoÓï¾ä£¬³ý·ÇÏÂÃæµÄÕâÖÖÇé¿ö£º
#define FREE(p) if(p) { \
free(p); \
p = NULL; \
}
main()
main()
{
char *fname=NULL, *lname=NULL, *mname=NULL;
fname = ( char* ) calloc ( 20, sizeof(char) );
if ( fname == NULL ){
goto ErrHandle;
}
lname = ( char* ) calloc ( 20, sizeof(char) );
if ( lname == NULL ){
goto ErrHandle;
}
mname = ( char* ) calloc ( 20, sizeof(char) );
if ( mname == NULL ){
goto ErrHandle;
}
......
ErrHandle:
ErrHandle:
&nb
Ïà¹ØÎĵµ£º
×÷Ò»¸ötcpµÄ·þÎñ³ÌÐò£¬Í¬Ê±¿ÉÄÜÓдóÁ¿µÄ¿Í»§¶ËÁ¬ÉÏÀ´£¬Ï£Íû·Ö±ð¼Çס¸÷¸ösocket
ËÓÐÊý¾Ý¹ýÀ´£¬¾Í¶Á³öÀ´£¬·Åµ½Ò»¸öÇëÇó¶ÓÁУ£ÕâЩÊÂÇéÓÃÒ»¸öÏß³ÌÍê³É
ÁíÍâÓÐÒ»¸ö½á¹û¶ÓÁУ¬Èç¹û½á¹ûÀï°üº¬ÁËsocketµÄ±àºÅ£¬ÓÃÒ»¸öÏß³ÌרÃÅ£º
È¡³öÀ´°´±àºÅÕÒ»ØÔÀ´·¢ËÍÕßsocket£¬·¢»Ø¸øÔÀ´µÄ¿Í»§¶Ë
»¹ÓÐÒ»¸ö¾ÍÊÇ´¦ÀíÏ ......
ÒÔÏÂÈ«ÎÄתÔØ×Ôhttp://www.keil.com/support/docs/50.htm Copyright © 2010 Keil™, An ARM® Company.
Information in this ar ......
¼ÙÉèxmlÎļþÊÇ
<?xml version="1.0" encoding="gb2312" ?>
- <books auth="wren">
- <book id="B01">
<name>¹þÀﲨÌØ </name>
<price>10 </price>
<memo>ÕâÊÇÒ»±¾ºÜºÃ¿´µÄÊé¡£ </memo>
</book>
- <boo ......
Ö»ÊÇÓÐÈËÇ£É浽д³ÌÐòµÄ,ÎÒ¾Í˵˵.Å®Ö÷½ÇÈç¹û²»³öÀ´³ÎÇå¾ÍÒ»±²×Ó±»»ÙÁË.У·çÑϽ÷µÄÇ廪ҲÓÐÕâÖÖÀÄSµÄÐÐΪÓе㲻¿É˼Òâ.ÕÒ³ÌÐòԱд×÷ÒµÖ»ÊǸö·ÖÊֵĽè¿Ú°É.Å®Ö÷½Ç»¹Â÷ÇåÐãµÄ.³öÀ´ÌÖÕ®µÄ"Ô©´óÍ·"ÆäʵҲ²»ÀíÖÇ,»ÙÁËÇ°Å®ÓѵÄÐÒ¸£ºÜºÃÂð?
µ«Ô¸CÓïÑÔÃÅÖ»ÊǸöÓéÀÖ ......
ʲôÊǺõijÌÐòÔ±£¿ÊDz»ÊǶ®µÃºÜ¶à¼¼Êõϸ½Ú£¿»¹ÊǶ®µ×²ã±à³Ì£¿»¹ÊDZà³ÌËٶȱȽϿ죿
ÎÒ¾õµÃ¶¼²»ÊÇ¡£¶ÔÓÚһЩ¼¼Êõϸ½ÚÀ´ËµºÍµ×²ãµÄ¼¼Êõ£¬Ö»Òª¿´°ïÖú£¬²é×ÊÁϾÍÄÜÕÒµ½£¬¶Ô
ÓÚËٶȿ죬ֻҪ±àµÃ¶àÒ²¾ÍÊìÄÜÉúÇÉÁË¡£
ÎÒÈÏΪºÃµÄ³ÌÐòÔ±Ó¦¸ÃÓÐÒÔϼ¸·½ÃæµÄËØÖÊ£º
1¡¢ÓÐרÑо«Éñ£¬ÇÚѧÉÆÎÊ¡¢¾ÙÒ»·´ ......