[תÔØ]C/C++ÓïÑÔÎóÇøÒ» —— void main( )
ÔÚÍøÉÏ¿´µ½ÁËÕâƪÎÄÕ£¬·Ç³£²»´í£¬»ñÒæ·Ëdz£¬ÓÚÊÇת¹ýÀ´£¬Ï£ÍûÄܶԴó¼ÒÓÐËùñÔÒæ¡£ÎÄÕÂÔ×÷Õߣºantigloss http://free3.e-168.cn/antigloss/
ºÜ¶àÈËÉõÖÁÊÐÃæÉϵÄһЩÊé¼®£¬¶¼Ê¹ÓÃÁËvoid main( ) £¬ÆäʵÕâÊÇ´íÎóµÄ¡£C/C++ ÖдÓÀ´Ã»Óж¨Òå¹ývoid main( ) ¡£C++ Ö®¸¸ Bjarne Stroustrup ÔÚËûµÄÖ÷Ò³É쵀 FAQ ÖÐÃ÷È·µØд×Å The definition void main( ) { /* ... */ } is not and never has been C++, nor has it even been C.£¨ void main( ) ´ÓÀ´¾Í²»´æÔÚÓÚ C++ »òÕß C £©¡£ÏÂÃæÎÒ·Ö±ð˵һÏ C ºÍ C++ ±ê×¼ÖÐ¶Ô main º¯ÊýµÄ¶¨Òå¡£
1. C
ÔÚ C89 ÖУ¬main( ) ÊÇÕýÈ·µÄ¡£Brian W. Kernighan ºÍ Dennis M. Ritchie µÄ¾µä¾ÞÖø The C programming Language£¨¡¶C ³ÌÐòÉè¼ÆÓïÑÔ¡·£©ÓõľÍÊÇ main( )¡£²»¹ýÔÚ×îÐ嵀 C99 ±ê×¼ÖУ¬Ö»ÓÐÒÔÏÂÁ½ÖÖ¶¨Ò巽ʽÊÇÕýÈ·µÄ£º
int main( void )
int main( int argc, char *argv[] )
£¨²Î¿¼×ÊÁÏ£ºISO/IEC 9899:1999 (E) Programming languages — C 5.1.2.2.1 Program startup£©
µ±È»£¬ÎÒÃÇÒ²¿ÉÒÔ×öÒ»µãССµÄ¸Ä¶¯¡£ÀýÈ磺char *argv[] ¿ÉÒÔд³É char **argv£»argv ºÍ argc ¿ÉÒԸijɱðµÄ±äÁ¿Ãû£¨Èç intval ºÍ charval£©£¬²»¹ýÒ»¶¨Òª·ûºÏ±äÁ¿µÄÃüÃû¹æÔò¡£
Èç¹ûÄã²»ÐèÒª´ÓÃüÁîÐÐÖлñÈ¡²ÎÊý£¬ÇëÓà int main( void ) £»·ñÔòÇëÓà int main( int argc, char *argv[] ) ¡£
main º¯ÊýµÄ·µ»ØÖµÀàÐͱØÐëÊÇ int £¬ÕâÑù·µ»ØÖµ²ÅÄÜ´«µÝ¸ø³ÌÐòµÄ¼¤»îÕߣ¨Èç²Ù×÷ϵͳ£©¡£
Èç¹û main º¯ÊýµÄ×îºóûÓÐд return Óï¾äµÄ»°£¬C99 ¹æ¶¨±àÒëÆ÷Òª×Ô¶¯ÔÚÉú³ÉµÄÄ¿±êÎļþÖУ¨Èç exe Îļþ£©¼ÓÈë return 0 £¬±íʾ³ÌÐòÕý³£Í˳ö¡£²»¹ý£¬ÎÒ»¹Êǽ¨ÒéÄã×îºÃÔÚ main º¯ÊýµÄ×îºó¼ÓÉÏ return Óï¾ä£¬ËäȻûÓÐÕâ¸ö±ØÒª£¬µ«ÕâÊÇÒ»¸öºÃµÄÏ°¹ß¡£×¢Ò⣬vc6 ²»»áÔÚÉú³ÉµÄÄ¿±êÎļþÖмÓÈë return 0 £¬´ó¸ÅÊÇÒòΪ vc6 ÊÇ 98 ÄêµÄ²úÆ·£¬ËùÒԲŲ»Ö§³ÖÕâ¸öÌØÐÔ¡£ÏÖÔÚÃ÷°×ÎÒΪʲô½¨ÒéÄã×îºÃ¼ÓÉÏ return Óï¾äÁË°É£¡²»¹ý£¬gcc3.2£¨Linux ϵ
Ïà¹ØÎĵµ£º
1. memcpyº¯ÊýµÄʵÏÖ
Ê×ÏȶÔÕâ¸öº¯Êý×öһЩ˵Ã÷¡£
#include <string.h>
void *memcpy(void *to, const void *from, size_t count)
º¯Êýmemcpy()´ÓfromÖ¸ÏòµÄÊý×éÏòtoÖ¸ÏòµÄÊý×鸴ÖÆcount¸ö×Ö·û¡£Èç¹ûÁ½Êý×éÖصþ£¬²»¶¨Ò庯ÊýµÄÐÐΪ¡£
ÔÚC99ÖУ¬toºÍfromÓÉrestrictÐÞÊΡ£
ÏÈÀ´¿´¿´Î¢ÈíµÄʵÏÖ£º
void * __cdecl m ......
CÓïÑԵıê×¼¿âº¯Êý°üÀ¨Ò»ÏµÁÐÈÕÆÚºÍʱ¼ä´¦Àíº¯Êý£¬ËüÃǶ¼ÔÚÍ·ÎļþÖÐ˵Ã÷¡£ÏÂÃæÁгöÁËÕâЩº¯Êý¡£ÔÚÍ·ÎļþÖж¨ÒåÁËÈýÖÖÀàÐÍ£ºtime_t£¬struct tmºÍclock_t¡£
ÔÚÖÐ˵Ã÷µÄCÓïÑÔʱ¼äº¯Êý & ......
ÓÃVIM±àдC/C++³ÌÐò£¨×ªÔØ£©
ÓÃVIM±àдC/C++³ÌÐò
ViÊÇUnixÏÂ×î³£ÓõÄÎı¾±à¼Æ÷¡£VIM£¨Vi IMproved£©ÔòÊÇËüµÄÔöÇ¿°æ¡£ÓÐÈ˳£³£ÄÃVIMºÍemacs±È½Ï£¬VIM¾¡¹Ü²»ÏóemacsÄÇÑùÓÐÄÇô¶àµÄ¹¦ÄÜ£¬µ«ÊDZÈemacs¸ü·½±ã¡¢ºÃÓá£ÓùýemacsµÄÈ˿϶¨»áΪemacsµÄһЩ¿ì½Ý¼ü¸Ðµ½·³ÄÕ£¬ÓÐʱºòÓÃÕæÏ£Íû×Ô¼ºÓаËÖ»ÊÖ¡£VIMµÄѧϰÇúÏßÒ²²»ÏóemacsÄ ......
תע:
½ñÌìÓÐÍøÓÑÎʵ½Õâ¸öÎÊÌâ,ÓÚÊÇÔÚÍøÉÏËÑË÷ÁËÒ»ÏÂ,תÌùÕâ´Ë.
ÏàËƵÄÌ«¶àÁË,³ö´¦²»Ïê.Ôڴ˸ÐлÔ×÷Õß¾«²Ê½²½â.
Ò»¡¢Ô¤±¸ÖªÊ¶—³ÌÐòµÄÄÚ´æ·ÖÅä
Ò»¸öÓÉc/C++±àÒëµÄ³ÌÐòÕ¼ÓõÄÄÚ´æ·ÖΪÒÔϼ¸¸ö²¿·Ö
1¡¢Õ»Çø£¨stack£©— ÓɱàÒëÆ÷×Ô¶¯·ÖÅäÊÍ·Å £¬´æ·Åº¯ÊýµÄ²ÎÊýÖµ£¬¾Ö²¿±äÁ¿µÄÖµµÈ¡£Æä²Ù×÷·½Ê½Àà ......
C/C++±ÊÊÔÌâϵÁÐ
Ô¤´¦ÀíÆ÷£¨Preprocessor£©
1. ÓÃÔ¤´¦ÀíÖ¸Áî#define ÉùÃ÷Ò»¸ö³£Êý£¬ÓÃÒÔ±íÃ÷1ÄêÖÐÓжàÉÙÃ루ºöÂÔÈòÄêÎÊÌ⣩
#define SECONDS_PER_YEAR (60 * 60 * 24 * 365)UL
ÎÒÔÚÕâÏë¿´µ½¼¸¼þÊÂÇ飺
1). #define Óï·¨µÄ»ù±¾ÖªÊ¶£¨ÀýÈ磺²»ÄÜÒԷֺŽáÊø£¬À¨ºÅµÄʹÓ㬵ȵȣ©
2). ¶®µÃÔ¤´¦ÀíÆ÷½«ÎªÄã¼ÆËã³ ......