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

C/C++±à³Ì¼¼ÄÜ¡¾ÕûÀí¡¿

Ô¤´¦ÀíÆ÷£¨Preprocessor£©
1. ÓÃÔ¤´¦ÀíÖ¸Áî#define ÉùÃ÷Ò»¸ö³£Êý£¬ÓÃÒÔ±íÃ÷1ÄêÖÐÓжàÉÙÃ루ºöÂÔÈòÄêÎÊÌ⣩
#define SECONDS_PER_YEAR (60 * 60 * 24 * 365)UL
ÎÒÔÚÕâÏë¿´µ½¼¸¼þÊÂÇ飺
1). #define Óï·¨µÄ»ù±¾ÖªÊ¶£¨ÀýÈ磺²»ÄÜÒԷֺŽáÊø£¬À¨ºÅµÄʹÓ㬵ȵȣ©
2). ¶®µÃÔ¤´¦ÀíÆ÷½«ÎªÄã¼ÆËã³£Êý±í´ïʽµÄÖµ£¬Òò´Ë£¬Ö±½Óд³öÄãÊÇÈçºÎ¼ÆËãÒ»ÄêÖÐÓжàÉÙÃë¶ø²»ÊǼÆËã³öʵ¼ÊµÄÖµ£¬ÊǸüÇåÎú¶øûÓдú¼ÛµÄ¡£
3). Òâʶµ½Õâ¸ö±í´ïʽ½«Ê¹Ò»¸ö16λ»úµÄÕûÐÍÊýÒç³ö-Òò´ËÒªÓõ½³¤ÕûÐÍ·ûºÅL,¸æËß±àÒëÆ÷Õâ¸ö³£ÊýÊǵij¤ÕûÐÍÊý¡£
4). Èç¹ûÄãÔÚÄãµÄ±í´ïʽÖÐÓõ½UL£¨±íʾÎÞ·ûºÅ³¤ÕûÐÍ£©£¬ÄÇôÄãÓÐÁËÒ»¸öºÃµÄÆðµã¡£¼Çס£¬µÚÒ»Ó¡ÏóºÜÖØÒª¡£
****UL¸Ã·Åµ½À¨ºÅÀïÃæ°É£¿
2. дһ¸ö“±ê×¼”ºêMIN£¬Õâ¸öºêÊäÈëÁ½¸ö²ÎÊý²¢·µ»Ø½ÏСµÄÒ»¸ö¡£
#define MIN(A,B) ((A) <= (B) (A) : )) 
CC++ÊÔÌ⼯ CC++ DevelopmentÕâ¸ö²âÊÔÊÇΪÏÂÃæµÄÄ¿µÄ¶øÉèµÄ£º
1). ±êʶ#defineÔÚºêÖÐÓ¦ÓõĻù±¾ÖªÊ¶¡£ÕâÊǺÜÖØÒªµÄ£¬ÒòΪֱµ½Ç¶Èë(inline)²Ù×÷·û±äΪ±ê×¼CµÄÒ»²¿·Ö£¬ºêÊÇ·½±ã²úÉúǶÈë´úÂëµÄΨһ·½·¨£¬¶ÔÓÚǶÈëʽϵͳÀ´Ëµ£¬ÎªÁËÄÜ´ïµ½ÒªÇóµÄÐÔÄÜ£¬Ç¶Èë´úÂë¾­³£ÊDZØÐëµÄ·½·¨¡£
2). ÈýÖØÌõ¼þ²Ù×÷·ûµÄ֪ʶ¡£Õâ¸ö²Ù×÷·û´æÔÚCÓïÑÔÖеÄÔ­ÒòÊÇËüʹµÃ±àÒëÆ÷ÄܲúÉú±Èif-then-else¸üÓÅ»¯µÄ´úÂ룬Á˽âÕâ¸öÓ÷¨ÊǺÜÖØÒªµÄ¡£
3). ¶®µÃÔÚºêÖÐСÐĵذѲÎÊýÓÃÀ¨ºÅÀ¨ÆðÀ´
4). ÎÒÒ²ÓÃÕâ¸öÎÊÌ⿪ʼÌÖÂÛºêµÄ¸±×÷Óã¬ÀýÈ磺µ±ÄãдÏÂÃæµÄ´úÂëʱ»á·¢ÉúʲôÊ£¿
Least = MIN(*p++, b);
3. Ô¤´¦ÀíÆ÷±êʶ#errorµÄÄ¿µÄÊÇʲô£¿
Èç¹ûÄã²»ÖªµÀ´ð°¸£¬Çë¿´²Î¿¼ÎÄÏ×1¡£ÕâÎÊÌâ¶ÔÇø·ÖÒ»¸öÕý³£µÄ»ï¼ÆºÍÒ»¸öÊé´ô×ÓÊǺÜÓÐÓõġ£Ö»ÓÐÊé´ô×ӲŻá¶ÁCÓïÑԿα¾µÄ¸½Â¼È¥ÕÒ³öÏóÕâÖÖ
ÎÊÌâµÄ´ð°¸¡£µ±È»Èç¹ûÄã²»ÊÇÔÚÕÒÒ»¸öÊé´ô×Ó£¬ÄÇôӦÊÔÕß×îºÃÏ£Íû×Ô¼º²»ÒªÖªµÀ´ð°¸¡£
ËÀÑ­»·£¨Infinite loops£©
4. ǶÈëʽϵͳÖо­³£ÒªÓõ½ÎÞÏÞÑ­»·£¬ÄãÔõôÑùÓÃC±àдËÀÑ­»·ÄØ£¿
Õâ¸öÎÊÌâÓü¸¸ö½â¾ö·½°¸¡£ÎÒÊ×Ñ¡µÄ·½°¸ÊÇ£º
while(1) { }
һЩ³ÌÐòÔ±¸üϲ»¶ÈçÏ·½°¸£º
for(;;) { }
Õâ¸öʵÏÖ·½Ê½ÈÃÎÒΪÄÑ£¬ÒòΪÕâ¸öÓ﷨ûÓÐÈ·Çбí´ïµ½µ×Ôõô»ØÊ¡£Èç¹ûÒ»¸öÓ¦ÊÔÕ߸ø³öÕâ¸ö×÷Ϊ·½°¸£¬ÎÒ½«ÓÃÕâ¸ö×÷Ϊһ¸ö»ú»áȥ̽¾¿ËûÃÇÕâÑù×öµÄ
»ù±¾Ô­Àí¡£Èç¹ûËûÃǵĻù±¾´ð°¸ÊÇ£º“ÎÒ±»½Ì×ÅÕâÑù×ö£¬µ«´ÓûÓÐÏëµ½¹ýΪʲô¡£”Õâ»á¸øÎÒÁôÏÂÒ»¸ö»µÓ¡Ïó¡£
µÚÈý¸ö·½°¸ÊÇÓà goto
Loop:

goto Loop;
Ó¦ÊÔÕß


Ïà¹ØÎĵµ£º

£¨×ª£©ÓÃVIM±àдC/C++³ÌÐò

ÓÃVIM±àдC/C++³ÌÐò£¨×ªÔØ£©
ÓÃVIM±àдC/C++³ÌÐò
ViÊÇUnixÏÂ×î³£ÓõÄÎı¾±à¼­Æ÷¡£VIM£¨Vi IMproved£©ÔòÊÇËüµÄÔöÇ¿°æ¡£ÓÐÈ˳£³£ÄÃVIMºÍemacs±È½Ï£¬VIM¾¡¹Ü²»ÏóemacsÄÇÑùÓÐÄÇô¶àµÄ¹¦ÄÜ£¬µ«ÊDZÈemacs¸ü·½±ã¡¢ºÃÓá£ÓùýemacsµÄÈ˿϶¨»áΪemacsµÄһЩ¿ì½Ý¼ü¸Ðµ½·³ÄÕ£¬ÓÐʱºòÓÃÕæÏ£Íû×Ô¼ºÓаËÖ»ÊÖ¡£VIMµÄѧϰÇúÏßÒ²²»ÏóemacsÄ ......

c fopenº¯Êý

[CÓïÑÔ]fopen()º¯ÊýµÄ²ÎÊý˵Ã÷
2007Äê06ÔÂ05ÈÕ ÐÇÆÚ¶þ 23:55
¸ñʽ£ºÎļþÖ¸ÕëÃû=fopen(ÎļþÃû£¬Ê¹ÓÃÎļþ·½Ê½)
²ÎÊý£º
ÎļþÃû ÒâÒå
"C:/temp/temp.txt" Îļþ C:\temp\temp.txt
ÎļþʹÓ÷½Ê½ ¡¡ Òâ Òå
“rt”¡¡¡¡¡¡¡¡¡¡Ö»¶Á´ò¿ªÒ»¸öÎı¾Îļþ£¬Ö»ÔÊÐí¶ÁÊý¾Ý
“wt”¡¡¡¡¡¡¡¡    ֻд ......

C/C++ ÄÚ´æ¹ÜÀí Heap vs Stack

 
תע:
½ñÌìÓÐÍøÓÑÎʵ½Õâ¸öÎÊÌâ,ÓÚÊÇÔÚÍøÉÏËÑË÷ÁËÒ»ÏÂ,תÌùÕâ´Ë.
ÏàËƵÄÌ«¶àÁË,³ö´¦²»Ïê.Ôڴ˸Ðлԭ×÷Õß¾«²Ê½²½â.
Ò»¡¢Ô¤±¸ÖªÊ¶—³ÌÐòµÄÄÚ´æ·ÖÅä
Ò»¸öÓÉc/C++±àÒëµÄ³ÌÐòÕ¼ÓõÄÄÚ´æ·ÖΪÒÔϼ¸¸ö²¿·Ö
1¡¢Õ»Çø£¨stack£©— ÓɱàÒëÆ÷×Ô¶¯·ÖÅäÊÍ·Å £¬´æ·Åº¯ÊýµÄ²ÎÊýÖµ£¬¾Ö²¿±äÁ¿µÄÖµµÈ¡£Æä²Ù×÷·½Ê½Àà ......

C/C++Èí¼þ¹¤³Ìʦ±ÊÊÔÌâ

 
C/C++±ÊÊÔÌâϵÁÐ
Ô¤´¦ÀíÆ÷£¨Preprocessor£©
1. ÓÃÔ¤´¦ÀíÖ¸Áî#define ÉùÃ÷Ò»¸ö³£Êý£¬ÓÃÒÔ±íÃ÷1ÄêÖÐÓжàÉÙÃ루ºöÂÔÈòÄêÎÊÌ⣩
#define SECONDS_PER_YEAR (60 * 60 * 24 * 365)UL
ÎÒÔÚÕâÏë¿´µ½¼¸¼þÊÂÇ飺
1). #define Óï·¨µÄ»ù±¾ÖªÊ¶£¨ÀýÈ磺²»ÄÜÒԷֺŽáÊø£¬À¨ºÅµÄʹÓ㬵ȵȣ©
2). ¶®µÃÔ¤´¦ÀíÆ÷½«ÎªÄã¼ÆËã³ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ