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

cÖÐÄÚ´æ·Ö²¼

¶ÑºÍÕ»µÄÇø±ð
Ò»¡¢Ô¤±¸ÖªÊ¶—³ÌÐòµÄÄÚ´æ·ÖÅä
Ò»¸öÓÉc/C++±àÒëµÄ³ÌÐòÕ¼ÓõÄÄÚ´æ·ÖΪÒÔϼ¸¸ö²¿·Ö
1¡¢Õ»Çø£¨stack£©— ÓɱàÒëÆ÷×Ô¶¯·ÖÅäÊÍ·Å £¬´æ·Åº¯ÊýµÄ²ÎÊýÖµ£¬¾Ö²¿±äÁ¿µÄÖµµÈ¡£Æä²Ù×÷·½Ê½ÀàËÆÓÚÊý¾Ý½á¹¹ÖеÄÕ»¡£
2¡¢¶ÑÇø£¨heap£©— Ò»°ãÓɳÌÐòÔ±·ÖÅäÊÍ·Å£¬ Èô³ÌÐòÔ±²»ÊÍ·Å£¬³ÌÐò½áÊøʱ¿ÉÄÜÓÉOS»ØÊÕ ¡£×¢ÒâËüÓëÊý¾Ý½á¹¹ÖеĶÑÊÇÁ½»ØÊ£¬·ÖÅ䷽ʽµ¹ÊÇÀàËÆÓÚÁ´±í£¬ºÇºÇ¡£
3¡¢È«¾ÖÇø£¨¾²Ì¬Çø£©£¨static£©—£¬È«¾Ö±äÁ¿ºÍ¾²Ì¬±äÁ¿µÄ´æ´¢ÊÇ·ÅÔÚÒ»¿éµÄ£¬³õʼ»¯µÄÈ«¾Ö±äÁ¿ºÍ¾²Ì¬±äÁ¿ÔÚÒ»¿éÇøÓò£¬ δ³õʼ»¯µÄÈ«¾Ö±äÁ¿ºÍδ³õʼ»¯µÄ¾²Ì¬±äÁ¿ÔÚÏàÁÚµÄÁíÒ»¿éÇøÓò¡£ - ³ÌÐò½áÊøºóÓÐϵͳÊÍ·Å
4¡¢ÎÄ×Ö³£Á¿Çø—³£Á¿×Ö·û´®¾ÍÊÇ·ÅÔÚÕâÀïµÄ¡£ ³ÌÐò½áÊøºóÓÉϵͳÊÍ·Å
5¡¢³ÌÐò´úÂëÇø—´æ·Åº¯ÊýÌåµÄ¶þ½øÖÆ´úÂë¡£
¶þ¡¢Àý×Ó³ÌÐò
ÕâÊÇÒ»¸öÇ°±²Ð´µÄ£¬·Ç³£Ïêϸ
//main.cpp
int a = 0; È«¾Ö³õʼ»¯Çø
char *p1; È«¾Öδ³õʼ»¯Çø
main()
{
int b; Õ»
char s[] = "abc"; Õ» ("abc"ÔÚÕ»ÖУ¬sÒ²ÊÇÕ»ÖеØÖ·³£Á¿£¬*s¼´Îªa£©
char *p2; Õ»
char *p3 = "123456"; 123456\0ÔÚ³£Á¿Çø£¬p3ÔÚÕ»ÉÏ¡£
static int c =0£» È«¾Ö£¨¾²Ì¬£©³õʼ»¯Çø
p1 = (char *)malloc(10);
p2 = (char *)malloc(20);
·ÖÅäµÃÀ´µÃ10ºÍ20×Ö½ÚµÄÇøÓò¾ÍÔÚ¶ÑÇø¡£
strcpy(p1, "123456"); 123456\0·ÅÔÚ³£Á¿Çø£¬±àÒëÆ÷¿ÉÄܻὫËüÓëp3ËùÖ¸ÏòµÄ"123456"ÓÅ»¯³ÉÒ»¸öµØ·½¡£
}
¶þ¡¢¶ÑºÍÕ»µÄÀíÂÛ֪ʶ
2.1ÉêÇ뷽ʽ
stack:
ÓÉϵͳ×Ô¶¯·ÖÅä¡£ ÀýÈ磬ÉùÃ÷ÔÚº¯ÊýÖÐÒ»¸ö¾Ö²¿±äÁ¿ int b; ϵͳ×Ô¶¯ÔÚÕ»ÖÐΪb¿ª±Ù¿Õ¼ä
heap:
ÐèÒª³ÌÐòÔ±×Ô¼ºÉêÇ룬²¢Ö¸Ã÷´óС£¬ÔÚcÖÐmallocº¯Êý
Èçp1 = (char *)malloc(10);
ÔÚC++ÖÐÓÃnewÔËËã·û
Èçp2 = (char *)malloc(10);
µ«ÊÇ×¢Òâp1¡¢p2±¾ÉíÊÇÔÚÕ»Öеġ£
2.2
ÉêÇëºóϵͳµÄÏìÓ¦
Õ»£ºÖ»ÒªÕ»µÄÊ£Óà¿Õ¼ä´óÓÚËùÉêÇë¿Õ¼ä£¬ÏµÍ³½«Îª³ÌÐòÌṩÄڴ棬·ñÔò½«±¨Òì³£ÌáʾջÒç³ö¡£
¶Ñ£ºÊ×ÏÈÓ¦¸ÃÖªµÀ²Ù×÷ϵͳÓÐÒ»¸ö¼Ç¼¿ÕÏÐÄÚ´æµØÖ·µÄÁ´±í£¬µ±ÏµÍ³ÊÕµ½³ÌÐòµÄÉêÇëʱ£¬
»á±éÀú¸ÃÁ´±í£¬Ñ°ÕÒµÚÒ»¸ö¿Õ¼ä´óÓÚËùÉêÇë¿Õ¼äµÄ¶Ñ½áµã£¬È»ºó½«¸Ã½áµã´Ó¿ÕÏнáµãÁ´±íÖÐɾ³ý£¬²¢½«¸Ã½áµãµÄ¿Õ¼ä·ÖÅä¸ø³ÌÐò£¬ÁíÍ⣬¶ÔÓÚ´ó¶àÊýϵͳ£¬»áÔÚÕâ¿éÄÚ´æ¿Õ¼äÖеÄÊ×µØÖ·´¦¼Ç¼±¾´Î·ÖÅäµÄ´óС£¬ÕâÑù£¬´úÂëÖеÄdeleteÓï¾ä²ÅÄÜÕýÈ·µÄÊͷű¾ÄÚ´æ¿Õ¼ä¡£ÁíÍ⣬ÓÉÓÚÕÒµ½µÄ¶Ñ½áµãµÄ´óС²»Ò»¶¨ÕýºÃµÈÓÚÉêÇëµÄ´óС£¬ÏµÍ³»á×Ô¶¯µÄ½«¶àÓàµÄÄDz¿·ÖÖØзÅÈë¿ÕÏÐÁ´±í


Ïà¹ØÎĵµ£º

CÖ¸Õ루1£©

CÓïÑÔ±ØÖª±Ø»á
Ö¸Õ룺
1.Ö¸ÕëÉùÃ÷ºóÒª¸³Öµ£¡·ñÔòÊÇ¿ÕÖ¸Õ룬¿É²»ÖªµÀÖ¸ÏòÁËÄÄÀï
ÀýÈ磺
void swap(int *a,int *b){
    int *tmp;
    *tmp=*a;
    *a=*b;
    *b=*tmp;
}
±¾À´ÊÇÏëÀûÓÃÉÏÃæµÄswapº¯ÊýʵÏÖÁ½¸öÊýµÄ»¥»»£¬µ«ÊÇ*tep=*a;Õâ¾ä»°ÊÇÓÐÎóµÄ ......

C/C++ Ò×´í

char c[] = "hello world"   ·ÖÅä¾Ö²¿Êý×é
char* c = "hello world"   ·ÖÅäÈ«¾ÖÊý×é  È«¾ÖÇøÓòµÄÖµÊDz»ÄܽøÐÐÐ޸ĵÄ
1 ³£Á¿Ö¸Õ룡Èç int b, c; int * const a = &b;
±íʾaÊÇÒ»¸ö³£Á¿Ö¸ÕëËüÖ¸Ïò±äÁ¿bµÄÄÚ´æ¡£µ«ÊÇÒòΪÊdz£Á¿Ö¸ÕëËùÒÔ²»ÄÜÔÙÓÃaÖ¸ÏòÆäËû±äÁ¿£¬Èç a = &c; ´íÎ󣡿ÉÒÔÐÞ¸ÄÖ ......

vim script ·ÖÏí£¨Ð´c/c ³ÌÐò´úÂ룩


×Ô¼ºÊ¹ÓÃvim±à¼­´úÂëÒ²ÊÇÓÐÒ»¶Îʱ¼äÀ´£¬Ä¿Ç°ÔĶÁ¡¢Ð޸ġ¢Ð´´úÂë»ù±¾¶¼Àë²»¿ªËûÁË¡£±¾ÈËʹÓùýµÄ±à¼­Æ÷ºÜÉÙ£¬ÒÔÇ°Ò»°ã¶¼ÊÇʹÓóÌÐò¿ª·¢IDE×Ô´øµÄ±à¼­Æ÷Щ´úÂ룬û¾õµÃʲô·½±ã¡£¿ªÊ¼Ê¹ÓÃvimµÄ¸Õ¸Õ½Ó´¥linux³ÌÐò¿ª·¢µÄʱºò£¬ÄÇʱ¿´µ½ÆäËûÈËÒ»°ã¶¼ÊÇÔÚwindowsÏÂʹÓÃSource Insight ±à¼­´úÂ룬ȻºóÔÚÐéÄâ»úlinuxÏÂmake¡£ÎұȽ ......

PythonµÄC/C++À©Õ¹

  Python
µÄ
C/C++
À©Õ¹
                         
By phidoit@gmail.com
 
¿ÉÀ©Õ¹ÐÔÊÇ
Python
µÄÒ»´óÌØÉ«£¬Ò»·½Ã棬ÓÉÓÚ
Python
ÊǽâÊÍÖ´Ðеģ¬Õâµ¼ÖÂÔËÐÐËÙ ......

Cö¾ÙÀàÐ͵ÄʹÓ÷½·¨

1.  ö¾ÙµÄ¶¨Òåö¾ÙÀàÐͶ¨ÒåµÄÒ»°ãÐÎʽΪ£º
    enum ö¾ÙÃû{ ö¾ÙÖµ±í };
ÔÚö¾ÙÖµ±íÖÐÓ¦ÂÞÁгöËùÓпÉÓÃÖµ¡£ÕâЩֵҲ³ÆΪö¾ÙÔªËØ¡£
ÀýÈ磺
   
¸Ãö¾ÙÃûΪweekday£¬Ã¶¾ÙÖµ¹²ÓÐ7¸ö£¬¼´Ò»ÖÜÖеÄÆßÌì¡£·²±»ËµÃ÷ΪweekdayÀàÐͱäÁ¿µÄÈ¡ÖµÖ»ÄÜÊÇÆßÌìÖеÄijһÌì¡£
2.  ö¾Ù±äÁ¿µ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ