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

cÖ¸ÕëµÄ¸÷ÖÖÓ÷¨ÊÔÑé

#include <iostream.h>
void fun0(int* p)
{
int* a=new int[3];
*a=0;
*(a+1)=1;
*(a+2)=2;
p=a;
}
void fun1(int* &p)
{
int* a=new int[3];
*a=0;
*(a+1)=1;
*(a+2)=2;
p=a;
}
void fun2(int* p)
{
*p=0;
*(p+1)=1;
*(p+2)=2;
}
//warning:returning address of local variable or temporary
int* fun3()
{
int a[]={1,2,3};
return a;
}
//warning C4172: returning address of local variable or temporary
int*& fun4()
{
int* a=new int[3];
a[0]=0;
a[1]=1;
a[2]=2;
return a;
}
void fun5(int* p[3])
{
*p[0]=0; *(p[0]+1)=10;
*p[1]=1; *(p[1]+1)=11;
*p[2]=2; *(p[2]+1)=12;
}
//cannot convert from 'int [3]' to 'int *&
/*
int*& fun6()
{
int a[]={1,2,3};
return a;
}
*/
void main()
{
int* p=new int[3];
// int* p; //runtime error:the memory connot be written
//it is necessory to allocate memory
cout<<"test: void fun0(int* p)"<<endl;
fun0(p);
for(int i=0;i<3;i++){
cout<<*(p+i)<<endl;
}
delete[3] p;
p=new int[3];
cout<<endl<<"test: void fun1(int* &p)"<<endl;
fun1(p);
for(i=0;i<3;i++){
cout<<*(p+i)<<endl;
}
delete[3] p;
p=new int[3];
cout<<endl<<"test: void fun2(int* p)"<<endl;
cout<<" allocate memory for the parameter"<<endl;
fun2(p);
for(i=0;i<3;i++){
cout<<" "<<*(p+i)<<endl;
}
cout<<" donot allocate memory for the parameter"<<endl;
cout<<" memory connot be written"<<endl;
/*
int* pt;
fun2(pt); //runtime error:memory connot be written
for(i=0;i<3;i++){
cout<<*(pt+i)<<endl;
}
*/
delete[3] p;
p=new int[3];
cout<<endl<<"test: int* fun3()"<<endl;
cout<<" debug assertion failed"<<endl;
/*
p=fun3(); //debug assertion failed
for(i=0;i<3;i++){
cout<<*(p+i)<<endl;
}
*/
delete[3] p;
p=new int[3];
cout<&


Ïà¹ØÎĵµ£º

C/C++ÖÐÊý×éÐβÎ(תÌû)

Ш×Ó
¡¡¡¡ È¥Ä꣬ÖÜÐÇÐÇ´ó¸çÔø¾­ÔÚVCKBASE/C++ÂÛ̳·¢±í¹ýһƪÎÄÕ“Êý×éÒýÓÃ"ÒÔ±ÜÃâ"Êý×é½µ½×”£¬µ±Ê±ÎÒ²»ÄÜÉîÈëÀí½âÕâÖÖÓ÷¨µÄº¬Ò壻ʱ¸ôÒ»Ä꣬ÎÒµÄ֪ʶÓм¸¾­´¸Á¶£¬ÖÕÓÚ¶Ô´ËÎÄÕ½¥ÓÐËùÎò£¬ËùÒÔ°ÑÎáËùÖª×÷Ïë¾ßÌåµÀÀ´£¬¾¹Ò²³ÉÁËһƪÎÄÕ¡£Ï£Íû±¾ÎÄÄܶÔÐÂÊÖÓÐËùÆôµÏ£¬Í¬Ê±Ò²Ï£Íû´ó¼Ò·¢ÏÖ±¾ÎÄÖеÄÊè©֮´¦ºó²»ÁßÁô ......

Linux: S3C2410µÄRTCÇý¶¯

----------------------------------------------------------------------------------------------------------------------------------------
/**/
/*
********************************************************************************************************
*  @Description:s3c2410µÄrtcÇý¶¯µÄʵ ......

ÓÃCÓïÑÔÀ©Õ¹PythonµÄ¹¦ÄÜ

µ±½ñÓÐÐí¶àÃâ·ÑµÄ RDBMS£¨Relational Database Management
System£¬¹ØϵÊý¾Ý¿â¹ÜÀíϵͳ£©£¬ÆäÖÐһЩÊÇ¿ª·ÅÔ´ÂëÈí¼þ£¬ÁíһЩÊÇÉÌÒµ³§ÉÌÌṩµÄÃâ·Ñ²úÆ·¡£Èç¹ûÄúÕýÔÚʹÓà C/C++¡¢Java™¡¢.NET
»ò PHP
¿ª·¢Ó¦ÓóÌÐò£¬ÏëÑ°ÕÒÒ»ÖÖ¿É¿¿µÄÊý¾Ý·þÎñÆ÷£¬Ï£ÍûËüÖ§³ÖÏȽøµÄ¼¼Êõ¡¢¾ßÓ⻶ÏÀ©´óµÄ¿ª·¢ÈËÔ±ÉçÇø²¢ÒѾ­²¿ÊðÔÚÐí¶à¹Ø¼ ......

c/c++ÄÚ´æ»®·Ö

      Ò»¡¢¸ö¾­¹ý±àÒëµÄC/C++µÄ³ÌÐòÕ¼ÓõÄÄÚ´æ·Ö³ÉÒÔϼ¸¸ö²¿·Ö:
      1¡¢Õ»Çø£¨stack£©£ºÓɱàÒëÆ÷×Ô¶¯·ÖÅäºÍÊÍ·Å £¬´æ·Åº¯ÊýµÄ²ÎÊýÖµ¡¢¾Ö²¿±äÁ¿µÄÖµµÈ£¬ÉõÖÁº¯ÊýµÄµ÷Óùý³Ì¶¼ÊÇÓÃÕ»À´Íê³É¡£Æä²Ù×÷·½Ê½ÀàËÆÓÚÊý¾Ý½á¹¹ÖеÄÕ»¡£ 
¡¡¡¡2¡¢¶ÑÇø£¨heap£© £ºÒ»°ãÓɳÌÐ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ