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; ´íÎ󣡿ÉÒÔÐÞ¸ÄÖ¸ÏòÄÚ´æµÄÖµ£¬Èç:*a = 20; BTW ³£Á¿Ö¸ÕëÉùÃ÷µÄʱºò±ØÐëÏòÎÒÄÇÑù¸³³õÖµ¡£
2 Ö¸Ïò³£Á¿µÄÖ¸Õ룡Èç int b, c; int const *a; a = &b; a = &c;
¶¼¿ÉÒÔ£¬Î¨¶ÀËüÖ¸ÏòµÄÄÚ´æ²»Äܱ»Ð޸ġ£È磺*a=20;ÕâÊÇÎ¥·¨µÄ£¡´íÎó£¡
Õâ¾ÍÊÇÖ÷ÒªÇø±ð£¡
BTW »¹ÓÐÒ»¸ö¼ÇסËûÃDz»Í¬ÐÎʽµÄ¼¼ÇÉ£¡¿´const¹Ø¼ü×Ö£¬ËûºóÃæµÄ²»¿ÉÐ޸ģ¬Èçint * const a = &b; ºóÃæÊÇa,Ôò˵Ã÷a²»ÄÜÐ޸ģ¡
int const * a = &b;ºóÃæÊÇ*aÔò˵Ã÷*a²»¿É±»Ð޸ģ¡
ÔںöàÊéÉÏ»òMSDNÊǾ³£Óà const int a=5;
int b=6;
const int *p=&b;
Æäʵ const int* ºÍint const* Ò»Ñù£¬¾ÍÊdz£Ö¸Õë Ò²¾ÍÊÇËüËùÖ¸ÏòµÄÊý¾Ý£¨ÔÚÕâÊÇint£©Êdz£Á¿£¬Ëü×Ô¼ºµÄÊý¾ÝÀàÐÍÊÇconst int*
»¹ÓÐconst int *p=&b;ÊÇ¿ÉÒ﵀ ËäÈ»b²»Êdz£Á¿¡£
µ«ÊÇ const int a=6;
int *p=&a;
»á±¨´í£¬ÒòΪËüÏû³ýÁËaµÄconstÊôÐÔ
**********************************************
*******ÎÒÃÇ¿ÉÒÔ×ܽáÒ»ÏÂ********
1. ¶ÔÓÚ³£Á¿£¨·ûºÅ³£Á¿£©ºÍ³£Ö¸Õë¡¢³£ÒýÓó£¶ÔÏóÉùÃ÷¶¼ÊÇÒ»ÑùµÄ
¶¨Òå¸ñʽ£º const Êý¾ÝÀàÐÍ ³£Á¿Ãû=³£Á¿Öµ£»
»ò Êý¾ÝÀàÐÍ const ³£Á¿Ãû=³£Á¿Öµ£»
ÀýÈ磺const int a=7; »ò int const a=7;£¨·ûºÅ³£Á¿£©
int b=5;
const int *p=&b; »ò int const *p=&b;(³£Ö¸Õ룩
const int &m=b;£¨³£ÒýÓã©
const Point pt; »ò Point const pt; //³£¶ÔÏó²»ÄܸüÐÂ
³£Ö¸ÕëºÍ³£ÒýÓÃÔÚ¹¦ÄÜÉÏÓÐËùÏÞÖÆ£¬¾ÍÊDz»ÄÜͨ¹ýËûÃǸü¸ÄÆäÖ¸ÏòµÄ±äÁ¿µÄÊý¾Ý£¨Öµ£©
2. Ö¸Õë³£Á¿
¶¨Òå¸ñʽ£º Êý¾ÝÀàÐÍ *const Ö¸Õë³£Á¿=³£Á¿Öµ£»
Èçchar ch,*const pch=&ch;(ÎÒÊÇÒ»²½Íê³ÉµÄ£¬ÄãÒ²¿ÉÒÔ·Ö¿ª£©
Ò²¾ÍÊÇ˵Õâ¸öÖ¸Õë±¾ÉíÊǸö³£Á¿£¬²»¿É¸Ä±ä£¬¼´ËüËùÖ¸ÏòµÄµØÖ·Êǹ̶¨µÄ¡£µ«£¬chÊÇ¿ÉÒԸıäµÄ¡£
Ïà¹ØÎĵµ£º
HÎļþºÍCÎļþÔõôÓÃÄØ£¿Ò»°ãÀ´Ëµ£¬HÎļþÖÐÊÇdeclare£¨ÉùÃ÷£©£¬CÎļþÖÐÊÇdefine£¨¶¨Ò壩¡£ÒòΪCÎļþÒª±àÒë³É¿âÎļþ£¨WindowsÏÂÊÇ.obj/.lib£¬UNIXÏÂÊÇ.o/.a£©£¬Èç¹û±ðÈËҪʹÓÃÄãµÄº¯Êý£¬ÄÇô¾ÍÒªÒýÓÃÄãµÄHÎļþ£¬ËùÒÔ£¬HÎļþÖÐÒ»°ãÊDZäÁ¿¡¢ºê¶¨Ò塢ö¾Ù¡¢½á¹¹ºÍº¯Êý½Ó¿ÚµÄÉùÃ÷£¬¾ÍÏñÒ»¸ö½Ó¿Ú˵Ã÷ÎļþÒ»Ñù¡£¶øCÎļþÔòÊÇʵÏÖϸ½Ú ......
getenv£¨È¡µÃ»·¾³±äÁ¿ÄÚÈÝ£©
Ïà¹Øº¯Êý putenv£¬setenv£¬unsetenv
±íÍ·Îļþ #include<stdlib.h>
¶¨Ò庯Êý char * getenv(const char *name);
º¯Êý˵Ã÷ getenv()ÓÃÀ´È¡µÃ²ÎÊýname»·¾³±äÁ¿µÄÄÚÈÝ¡£²ÎÊýnameΪ»·¾³±äÁ¿µÄÃû³Æ£¬Èç¹û¸Ã±äÁ¿´æÔÚÔò»á·µ»ØÖ¸Ïò¸ÃÄÚÈݵÄÖ¸Õë¡£»·¾³±äÁ¿µÄ¸ñʽΪname£½value¡£
·µ»ØÖµ Ö´Ðг ......
C++ÖеÄStaticÓÐÁ½¸ö×÷Óá£
1¡¢ ¾²Ì¬¾Ö²¿±äÁ¿
¾²Ì¬¾Ö²¿±äÁ¿ÔÚº¯ÊýÄÚ¶¨Òå ËüµÄÉú´æÆÚΪÕû¸öÔ´³ÌÐò£¬µ«ÊÇÆä×÷ÓÃÓòÔڸú¯ÊýÄÚ£¬Ö»ÄÜÔÚ¶¨Òå¸Ã±äÁ¿µÄº¯ÊýÄÚʹÓøñäÁ¿¡£ ÔÊÐí¶Ô¹¹ÔìÀྲ̬¾Ö²¿Á¿¸³³õÖµ£¬Èôδ¸³ÒÔ³õÖµ£¬ÔòÓÉϵͳ×Ô¶¯¸³ÒÔ0Öµ¡£
void fun1()
{
static int i = 0;
......
¹ØÓÚ×éºÏÊý¼ÆËãµÄËã·¨ÎÒдÁ˺ü¸¸ö£¬·¢ÏÖÑî»ÔÈý½Ç²é±í·¨Ð§ÂʱȽϸߣ¡
²¢ÇÒÕâ¸öËã·¨ÀûÓÃC(n,k) = C(n,n-k)À´¼ò»¯Ñî»ÔÈý½ÇµÄÊý×飬Ëã·¨µÄʱ¼ä¸´ÔӶȱȽϵ͡£
Ô´´£¬Ë®Æ½ÓÐÏÞ£¬ÈçÓв»×㣬»¶ÓÖ¸³ö¡£
Mail£ºrainday163@163.com
ÏÂÃæÊÇÎÒдµÄ´úÂë²¢¸½´ø²âÊÔº¯Êý£ºDev-C++ 4.9.9.2ϲâÊÔͨ¹ý¡£
/*----------------- ......
CÓïÑÔ±ØÖª±Ø»á
Ö¸Õ룺
1.Ö¸ÕëÉùÃ÷ºóÒª¸³Öµ£¡·ñÔòÊÇ¿ÕÖ¸Õ룬¿É²»ÖªµÀÖ¸ÏòÁËÄÄÀï
ÀýÈ磺
void swap(int *a,int *b){
int *tmp;
*tmp=*a;
*a=*b;
*b=*tmp;
}
±¾À´ÊÇÏëÀûÓÃÉÏÃæµÄswapº¯ÊýʵÏÖÁ½¸öÊýµÄ»¥»»£¬µ«ÊÇ*tep=*a;Õâ¾ä»°ÊÇÓÐÎóµÄ ......