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

C/C++³ÌÐòÄÚ´æ·ÖÅäÏê½â

   
·ÇʱÉСñ2010ÐÂ¿î ¹¬Í¢¸´¹ÅÂÞÂíЬÕæƤÁ¹Ð¬ÊæÊÊƽµ×ЬŮЬ
189.0Ôª 
Ò»¸öÓÉ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£» //È«¾Ö£¨¾²Ì¬£©³õʼ»¯Çø
p1 = (char *)malloc(10);
p2 = (char *)malloc(20);
//·ÖÅäµÃÀ´µÃ10ºÍ20×Ö½ÚµÄÇøÓò¾ÍÔÚ¶ÑÇø¡£
strcpy(p1, "123456"); //123456\0·ÅÔÚ³£Á¿Çø£¬±àÒëÆ÷¿ÉÄܻὫËüÓëp3ËùÖ¸ÏòµÄ"123456"ÓÅ»¯³ÉÒ»¸öµØ·½¡£
}
===============
CÓïÑÔ³ÌÐòµÄÄÚ´æ·ÖÅ䷽ʽ
1.ÄÚ´æ·ÖÅ䷽ʽ
ÄÚ´æ·ÖÅ䷽ʽÓÐÈýÖÖ£º
[1]´Ó¾²Ì¬´æ ´¢ÇøÓò·ÖÅä¡£ÄÚ´æÔÚ³ÌÐò±àÒëµÄʱºò¾ÍÒѾ­·ÖÅäºÃ£¬Õâ¿éÄÚ´æÔÚ³ÌÐòµÄÕû¸öÔËÐÐÆڼ䶼´æÔÚ¡£ÀýÈçÈ«¾Ö±äÁ¿£¬static±äÁ¿¡£
[2]ÔÚÕ»ÉÏ´´½¨¡£ ÔÚÖ´Ðк¯Êýʱ£¬º¯ÊýÄÚ¾Ö²¿±äÁ¿µÄ´æ´¢µ¥Ôª¶¼¿ÉÒÔÔÚÕ»ÉÏ´´½¨£¬º¯ÊýÖ´ÐнáÊøʱÕâЩ´æ´¢µ¥Ôª×Ô¶¯±»ÊÍ·Å¡£Õ»ÄÚ´æ·ÖÅäÔËËãÄÚÖÃÓÚ´¦ÀíÆ÷µÄÖ¸ÁÖУ¬Ð§Âʺܸߣ¬µ« ÊÇ·ÖÅäµÄÄÚ´æÈÝÁ¿ÓÐÏÞ¡£
[3]´Ó¶ÑÉÏ·ÖÅ䣬Òà³Æ¶¯Ì¬ÄÚ´æ·ÖÅä¡£³ÌÐòÔÚÔËÐеÄʱºòÓÃmalloc»ònewÉêÇëÈÎÒâ¶àÉÙµÄÄڴ棬³ÌÐòÔ±×Ô¼º¸ºÔðÔÚºÎʱÓÃfree»òdeleteÊÍ·ÅÄÚ´æ¡£¶¯Ì¬ÄÚ´æµÄÉú´æÆÚÓɳÌÐòÔ±¾ö¶¨£¬Ê¹Ó÷dz£Áé»î£¬µ«Èç¹ûÔÚ¶ÑÉÏ·ÖÅäÁ˿ռ䣬¾ÍÓÐÔðÈλØÊÕËü£¬·ñÔòÔËÐеijÌÐò»á³öÏÖÄÚ´æй©£¬Æµ·±µØ·ÖÅäºÍÊͷŲ»Í¬´óСµÄ¶Ñ¿Õ¼ä½«»á²úÉú¶ÑÄÚËé¿é¡£
2.³ÌÐòµÄÄÚ´æ¿Õ¼ä
Ò»¸ö³ÌÐò½«²Ù×÷ ϵÍ


Ïà¹ØÎĵµ£º

Óà Eclipse ¿ª·¢C/C++

ÒªÏëÓÃeclipse¿ª·¢C/C++ Ê×ÏÈÒªÅäÖÃÒ»¸öC/C++µÄ±àÒë»·¾³£¬ÒòΪeclipse×ÔÉíÊDz»´øµÄ¡£ ÐèÒªÏÂÃæÕâÁ½¸ö±Ø²»¿ÉÉٵŤ¾ß 1.±àÒ빤¾ß MinGW£ºhttp://www.mingw.org/             Ö±½ÓÏÂÔصØÖ·£ºhttp://sourceforge.net/projects/mingw/files/ 2.eclipse²å¼þ CDT £ ......

C\C++ Notes

CµÄstaticµÄÓ÷¨:
1.¶ÔÓÚº¯ÊýÀïµÄ¾Ö²¿±äÁ¿,¸Ä±äµÄÊÇËüµÄÉú´æÖÜÆÚ,Õâ¸ö±äÁ¿»áÒ»Ö±´æÔÚ,µ½³ÌÐò½áÊø. º¯ÊýÍⲿ·ÃÎʲ»µ½Õâ¸ö±äÁ¿.
2.¶ÔÓÚÈ«¾ÖµÄ±äÁ¿,¸Ä±äµÄÊÇËüµÄ×÷Ó÷¶Î§,Õâ¸ö±äÁ¿Ö»ÔÚ±¾ÎļþÄÚÓÐЧ.ÆäËüµÄ.cÎļþ¿´²»µ½.
   µ±È»ËüµÄÉúÃüÖÜÆÚÊǺͳÌÐòÒ»ÑùµÄ ......

¡¾C/C++¡¿staticºÍconstµÄ±È½ÏºÍ½âÊÍ

ת
ÔØ×Ôhttp://www.builder.com.cn/
 
       static
ÊÇc++Öкܳ£ÓõÄÐÞÊηû£¬Ëü±»ÓÃÀ´¿ØÖƱäÁ¿µÄ´æ´¢·½Ê½ºÍ¿É¼ûÐÔ£¬ÏÂÃæÎÒ½«´Ó static ÐÞÊηûµÄ²úÉúÔ­Òò¡¢×÷ÓÃ̸Æð£¬È«Ãæ·ÖÎöstatic
ÐÞÊηûµÄʵÖÊ¡£
¡¡¡¡static µÄÁ½´ó×÷ÓÃ:
¡¡¡¡Ò»¡¢¿ØÖÆ´æ´¢·½Ê½£º
¡¡¡¡static±»ÒýÈëÒÔ¸æÖª±àÒëÆ÷£¬½«±ä ......

¿ìËÙÇóaµÄb´ÎÃݶÔcÈ¡Óà

¿ìËÙÃÝÈ¡Ä£ÀíÂÛ»ù´¡£º  ¼ÆËã a^b mod c ?
  ÓÉ(a x b) mod c=((a mod c) x b) mod c.
 ÎÒÃÇ¿ÉÒÔ½« bÏȱíʾ³É¾Í£º
   b=at2^t+at-1 2^t-1+……a02^0. (ai=[0,1]).
 ÕâÑùÎÒÃÇÓÉ a^b mod c=(a^(at2^t+at-12^t-1+…a02^0)mod c.
 È»¶øÎÒÃÇÇó  a^(2^(i+1)) ......

¹ØÓÚ extern "C"

µ±Õâ¸öÊÀ½ç»¹Ö»ÓÐCµÄʱºò£¬ÊDz»ÐèÒªextern "C"µÄ¡£
µ«ÊÇ£¬µ±C++³öÏÖÖ®ºó£¬ÓÐʱºò£¬ÎÒÃǾÍÐèÒªextern "C"ÁË¡£
ÄǾ¿¾¹ÊÇÔÚʲôÑùµÄÇé¿öÏ£¬ÎÒÃÇÐèÒªÓÃextern "C"ÄØ£¿
ÓÐÈË˵£¬ÊÇΪÁËCÄܹ»µ÷ÓÃC++£¬ÓÐÈË˵ÊÇΪÁËÔÚC++ÖÐÄܵ÷ÓÃCµÄ¿âº¯Êý¡£ÊDz»ÊÇ°ÑÄãŪºýÍ¿ÁË£¿
ÏÈ˵˵extern "C"ÊÇɶ×÷Óðɡ£
extern "C" ÊǸæËßC++±àÒëÆ÷£¬ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ