¼±ÎʸöcµÄÃæÊÔÌâ
C/C++ code:
void p1(const char **pname)
{
const char *name = "test1";
*pname = name;
}
void p2(const char **pname)
{
char *name = "test2";
*pname = name;
}
void p3(const char **pname)
{
char name[] = "test3";
*pname = name;
}
int main()
{
const char *name;
p1(&name);
printf("%s\n",name);
p2(&name);
printf("%s\n",name);
p3(&name);
printf("%s\n",name);
return 0;
}
´ð°¸ÊÇ test1 ºÍ test2¶¼ÄÜ´òÓ¡³öÀ´ test3²»ÄÜ´òÓ¡ÊÇgarbage
˵string¡°test1¡±ºÍ"test2"¶¼ÊÇglobal allocated onstatant
string"test3"ÊÇÔÚstackÉϵÄ
ÎÒ¾õµÃÕâ¸ö²»¶Ô°É~~
mainÀïÃæµÄconst char*name; ¼ÈÈ»const ¶¨ÒåµÄʱºò¾ÍÓ¦¸ÃÂíÉϸ³Öµ°É~
ÎÒ¾õµÃ"test1","test2","test3" ¶¼ÊÇÔÚstackÉϵÄ
Çë¸ßÈËÖ¸µã
лл
p1 p2ÖеÄname¶¼ÊÇÖ¸Õ룬ָÏòÁ˳£Á¿×Ö·û´®£¬Õâ¸öµØÖ·ÊÇÈ«¾ÖµÄ£¬²»»áÏú»Ù¡£
p3ÖÐnameÊǸöÊý×飬ÔÚstackÖУ¬²¢Óó£Á¿×Ö·û´®¸³Öµ¡£nameµÄµØÖ·²»Êdz£Á¿×Ö·û´®µÄµØÖ·£¬ËùÒÔº¯ÊýÍ˳öºóÏú»ÙÁË¡£
ȷʵ¿ÉÒÔ´ò³öÀ´£¬Ö¸ÕënameÊÇÔÚstackÉÏ£¬µ«¡°test1","test2"ÕâЩ×Ö·û´®ÊÇÔÚ¾²Ì¬´æÖüÇø
ËùÓеÄ×Ö·û´®×ÖÃæÖµ¶¼ÊÇ·ÖÅäÔÚ³£Á¿ÇøµÄ£¬ÕâÈý¸ö¶¼ÊÇÔÚ³£Á¿ÇøµÄ£¬Ç°Á½¸öÊǶ¨ÒåÖ¸ÕëÖ±½ÓÖ¸ÏòÕâ¿é³£Á¿Çø£¬ËùÒÔÄÜ´ò³öÀ´£¬µÚÈý¸öÊÇÏÈ·ÖÅäÒ»¸öÊý×éÈ»º
Ïà¹ØÎÊ´ð£º
±àÒëÆÕͨµÄcûÎÊÌâ°¡£¬µ«±àÒëjavahÉú³ÉµÄ¾Í±¨´í£º
gcc -O0 -g3 -Wall -c -fmessage-length=0 -oHelloWorld.o ..\HelloWorld.c
gcc -otest.exe HelloWorld.o
d:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../. ......
int a=2;
int i;
i=(a++)+(++a)+(a++)+(++a)+(a++);
printf("%d",i);
½á¹ûÊÇ20£¬Çë½â¶Á
ÕâÒѾ²»ÊÇÔ¾ÌùÁË£¬Ëͳ¼Æ¹ý½ñÌ ......
RT
pow(x,y)
exp( x, 1/y)
float x=27.0f;
float y=1/3.0f; //¿ª3´Î·½
float z=pow(x,y);
printf("%f",z);
¡£¡£¡£ ÊÇpow(x, 1/y)
Â¥ÉÏ ÎÒÔËÐÐÔõôÊÇ0 °¡
ÓÐûÓÐÕâÖÖд·¨ ......
ÎÒ¸öÈ˸оõÓеĵط½Ã»±ØÒª¿´£¬·±ËöµÃºÝ£¬ÓÃ×Ô¼º×ܽáµÄ·½·¨¸üºÃ£¬´ó¼Ò˵˵×Ô¼ºµÄÒâ¼û
ÎҸоõ±ã½Ý¼ÆËãÓë²»¶Ô³Æ±ß½çÍêÈ«¸ù¾Ý×Ô¼ºµÄ¾ÑéÀ´£¬Óò»×Å¿´Å¶£¬´ó¼Ò˵˵
Äã¿´²»¿´ÄÇÊÇÄãµÄÊÂ
Æäʵ¶¼ÊÇ»ù´¡µÄ¶«Î÷À²
......
ÈçºÎÓÃcʵÏÖ×Ô¶¯µÄtelnet¹¦ÄÜ,ÓÐËÖªµÀÔõôÓÃcÓïÑÔÀ´ÊµÏÖ¡£ÎÊÌâÖ÷ÒªÊÇtelnetµÄÓû§Ãû£¬ÃÜÂëÒª½»»¥Ê½µÄÊäÈ룬ÔõôÄܹ»ÓóÌÐòʵÏÖ°¡£¬¸ßÊÖÖ¸½Ì°¡
ÎÒÓÐÔ´Âë ÄãÒªµÄ»° ÁôÏÂÓÊÏä
flynecnt@qq.com ллÁË
liuzhizu1 ......