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

¹ØÓÚC/C++ÖÐÄÚ´æ¿Õ¼äµÄ»®·Ö

CAPTION: ¹ØÓÚC/C++ÖÐÄÚ´æ¿Õ¼äµÄ»®·Ö
AUTHOR: aIsland Õª×ÔÖйúITʵÑéÊÒ
DATE: 2010-05-30
E-MAIL: aIsland@live.cn
QQ: 418662213
P.S.
     1.Bolanlan|ËæÐÄhigh|aIsland Èý¸öÍøÃû¾ùΪ±¾ÈË
     2.ÉùÃ÷aIsland ËùÊÕ¼µÄËùÓÐÎÄÕÂÆäÖø×÷Ȩ¶¼ÊôÓÚÔ­´´×÷Õß
     3.ÒýÓÃÎÄÕÂÁ´½Ó£ºhttp://c.chinaitlab.com/system/792799.html
Ò»¡¢Ò»¸ö¾­¹ý±àÒëµÄC/C++µÄ³ÌÐòÕ¼ÓõÄÄÚ´æ·Ö³ÉÒÔϼ¸¸ö²¿·Ö£º
¡¡¡¡1¡¢Õ»Çø£¨stack£©£ºÓɱàÒëÆ÷×Ô¶¯·ÖÅäºÍÊÍ·Å £¬´æ·Åº¯ÊýµÄ²ÎÊýÖµ¡¢¾Ö²¿±äÁ¿µÄÖµµÈ£¬ÉõÖÁº¯ÊýµÄµ÷Óùý³Ì¶¼ÊÇÓÃÕ»À´Íê³É¡£Æä²Ù×÷·½Ê½ÀàËÆÓÚÊý¾Ý½á¹¹ÖеÄÕ»¡£
¡¡¡¡2¡¢¶ÑÇø£¨heap£© £ºÒ»°ãÓɳÌÐòÔ±ÊÖ¶¯ÉêÇëÒÔ¼°ÊÍ·Å£¬ Èô³ÌÐòÔ±²»ÊÍ·Å£¬³ÌÐò½áÊøʱ¿ÉÄÜÓÉOS»ØÊÕ ¡£×¢ÒâËüÓëÊý¾Ý½á¹¹ÖеĶÑÊÇÁ½»ØÊ£¬·ÖÅ䷽ʽÀàËÆÓÚÁ´±í¡£
¡¡¡¡3¡¢È«¾ÖÇø£¨¾²Ì¬Çø£©£¨static£©£ºÈ«¾Ö±äÁ¿ºÍ¾²Ì¬±äÁ¿µÄ´æ´¢ÊÇ·ÅÔÚÒ»¿éµÄ£¬³õʼ»¯µÄÈ«¾Ö±äÁ¿ºÍ¾²Ì¬±äÁ¿ÔÚÒ»¿éÇøÓò£¬ δ³õʼ»¯µÄÈ«¾Ö±äÁ¿ºÍδ³õʼ»¯µÄ¾²Ì¬±äÁ¿ÔÚÏàÁÚµÄÁíÒ»¿éÇøÓò¡£³ÌÐò½áÊøºóÓÉϵͳÊͷſռ䡣
¡¡¡¡4¡¢ÎÄ×Ö³£Á¿Çø£º³£Á¿×Ö·û´®¾ÍÊÇ·ÅÔÚÕâÀïµÄ¡£ ³ÌÐò½áÊøºóÓÉϵͳÊͷſռ䡣
¡¡¡¡5¡¢³ÌÐò´úÂëÇø£º´æ·Åº¯ÊýÌåµÄ¶þ½øÖÆ´úÂë¡£
¡¡¡¡ÏÂÃæµÄÀý×Ó¿ÉÒÔÍêȫչʾ²»Í¬µÄ±äÁ¿ËùÕ¼µÄÄÚ´æÇøÓò£º
¡¡¡¡//main.cpp
¡¡¡¡int a = 0; È«¾Ö³õʼ»¯Çø
¡¡¡¡char *p1; È«¾Öδ³õʼ»¯Çø
¡¡¡¡main()
¡¡¡¡{
¡¡¡¡int b; //Õ»ÖÐ
¡¡¡¡char s[] = "abc"; //Õ»ÖÐ
¡¡¡¡char *p2; //Õ»ÖÐ
¡¡¡¡char *p3 = "123456"; //123456\0ÔÚ³£Á¿Çø£¬p3ÔÚÕ»ÉÏ
¡¡¡¡static int c =0£» //È«¾Ö£¨¾²Ì¬£©³õʼ»¯Çø
¡¡¡¡//ÒÔÏ·ÖÅäµÃµ½µÄ10ºÍ20×Ö½ÚµÄÇøÓò¾ÍÔÚ¶ÑÇø
¡¡¡¡p1 = (char *)malloc(10);
¡¡¡¡p2 = new char[20];//(char *)malloc(20);
¡¡¡¡strcpy(p1, "123456"); //123456\0·ÅÔÚ³£Á¿Çø£¬±àÒëÆ÷¿ÉÄܻὫËüÓëp3ËùÖ¸ÏòµÄ"123456"ÓÅ»¯³ÉÒ»¸öµØ·½¡£
¡¡¡¡}
¡¡¡¡¶þ¡¢Õ»£¨stack£©ºÍ¶Ñ£¨heap£©¾ßÌåµÄÇø±ð¡£
¡¡¡¡1¡¢ÔÚÉêÇ뷽ʽÉÏ
¡¡¡¡Õ»£¨stack£©: ÏÖÔںܶàÈ˶¼³Æ֮Ϊ¶ÑÕ»£¬Õâ¸öʱºòʵ¼ÊÉÏ»¹ÊÇÖ¸µÄÕ»¡£ËüÓɱàÒëÆ÷×Ô¶¯¹ÜÀí£¬ÎÞÐèÎÒÃÇÊÖ¹¤¿ØÖÆ¡£ ÀýÈ磬ÉùÃ÷º¯ÊýÖеÄÒ»¸ö¾Ö²¿±äÁ¿ int b ϵͳ×Ô¶¯ÔÚÕ»ÖÐΪb¿ª±Ù¿Õ¼ä£»ÔÚµ÷ÓÃÒ»¸öº¯Êýʱ£¬ÏµÍ³×Ô¶¯µÄ¸øº¯ÊýµÄÐβαäÁ¿ÔÚÕ»Öпª±Ù¿Õ¼ä¡£
¡¡¡¡¶Ñ£¨heap£©: ÉêÇëºÍÊÍ·ÅÓɳÌÐòÔ±¿ØÖÆ£¬²¢Ö¸Ã÷´óС¡£ÈÝÒײúÉúmemory leak¡£
¡¡¡¡ÔÚCÖÐʹÓÃmallocº¯Êý¡£
¡¡¡


Ïà¹ØÎĵµ£º

ÉîÈëC/C++Ö®»ùÓÚCheckStackVarsµÄ°²È«¼ì²é£¨VS2008£©

×î½üһֱæ±ÏÒµµÄÏà¹ØÊÂÇ飬¼ÓÉϹ¤×÷£¬×ªÑۼ䣬ÓÖµ½Ôµ×ÁË£¬Ö®Ç°³ÐŵµÄÿÔÂһƪ²©ÎÄ£¬Ç°¼¸Ìì¾ÍÒ»Ö±ÔÚÑ°ÕÒµ½µ×Ҫдʲô£¬½üÁ½ÌìÓÖͻȻ·¢ÏÖÓкܶණÎ÷¿ÉÒÔд¡£±¾Æª¾ÍÏÈÑÓÐø֮ǰµÄһƪ»ùÓÚCookieµÄ°²È«¼ì²é»úÖÆ£¨ÉîÈëC/C++Ö®»ùÓÚCookieµÄ°²È«¼ì²é£¨VS2005£©£©À´½éÉÜÏÂÁíÍâÒ»ÖÖÔÚDEBUG°æ±¾Ïµİ²È«¼ì²é£¬Ò²¾ÍÊÇCheckStackVars¼ì ......

JSTL ʹÓà c:forEach

ÔÚ Web Ó¦ÓóÌÐò»·¾³ÖУ¬µü´úÖ÷ÒªÓÃÓڷôæºÍÏÔʾÊý¾Ý¼¯£¬Í¨³£ÊÇÒÔÁбí»ò±íÖеÄһϵÁÐÐеÄÐÎʽÏÔʾ¡£ÊµÏÖµü´úÄÚÈݵÄÖ÷Òª JSTL ²Ù×÷ÊÇ <c:forEach>; ¶¨ÖƱê¼Ç¡£¸Ã±ê¼ÇÖ§³ÖÁ½ÖÖ²»Í¬ÑùʽµÄµü´ú£ºÕûÊý·¶Î§Éϵĵü´ú£¨ÀàËÆ Java ÓïÑ﵀ for Óï¾ä£©ºÍ¼¯ºÏÉϵĵü´ú£¨ÀàËÆ Java ÓïÑ﵀ Iterator ºÍ Enumeration Àࣩ¡£
½øÐÐÕûÊ ......

ÓеÀÄÑÌâÁ·Ï°Èü2ÖеÄcÌâ

ÃèÊö ¸ø¶¨Ò»¸öÕûÊýÐòÁУ¬ÅжÏÆäÖÐÓжàÉÙ¸öÊý£¬µÈÓÚÊýÁÐÖÐÆäËûÁ½¸öÊýµÄºÍ¡£ ±ÈÈ磬¶ÔÓÚÊýÁÐ1 2 3 4, Õâ¸öÎÊÌâµÄ´ð°¸¾ÍÊÇ2, ÒòΪ3 = 2 + 1, 4 = 1 + 3¡£ ÊäÈë µÚÒ»ÐÐÊÇÒ»¸öÕûÊýT£¬±íʾһ¹²ÓжàÉÙ×éÊý¾Ý¡£ 1<= T <= 100
½ÓÏÂÀ´µÄÿ×éÊý¾Ý¹²Á½ÐУ¬µÚÒ»ÐÐÊÇÊýÁÐÖÐÊýµÄ¸öÊýn ( 1 <= n <= 100)£¬µÚ¶þÐÐÊÇÓÉn¸öÕûÊý×é³ ......

CµÄ18¸ö¾­µäÎÊÌâ¡£

1.ÕâÑùµÄ³õʼ»¯ÓÐʲôÎÊÌ⣿char *p = malloc(10); ±àÒëÆ÷Ìáʾ“·Ç·¨³õʼʽ” ÔÆÔÆ¡£
´ð:Õâ¸öÉùÃ÷ÊǾ²Ì¬»ò·Ç¾Ö
²¿±äÁ¿Â𣿺¯Êýµ÷ÓÃÖ»ÄܳöÏÖÔÚ×Ô¶¯±äÁ¿(¼´¾Ö²¿·Ç¾²Ì¬±äÁ¿) µÄ³õʼʽÖС£
ÒòΪ¾²Ì¬±äÁ¿µÄµØÖ·±ØÐëÔÚ±àÒëµÄ¹ý³ÌÖоÍÈ·¶¨ÏÂÀ´¶ømalloc()Éê
ÇëµÄÄÚ´æµØÖ·ÊÇÔÚÔËÐÐʱȷ¶¨µÄ¡£
2. *p++ ×ÔÔöp »¹ÊÇp ËùÖ ......

Beautify your c/c++ source code

http://uncrustify.sourceforge.net/
Ident code, aligning on parens, assignments, etc
Align on '=' and variable definitions
Align structure initializers
Align #define stuff
Align backslash-newline stuff
Reformat comments (a little bit)
Fix inter-character spacing
Add or remove parens on return ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ