?? chapter1-3.cpp
字號:
//文件名:CHAPTER1-3.cpp
#include<iostream.h>
#include<stdio.h>
void main()
{
unsigned int *a,*b;
struct dt{unsigned int mm,dd,yy;};
a=new unsigned int(20); /*使a指向一個機器字長的地址單元并賦初值20,*/
/*即等效于a=new unsigned int; *a=20;*/
b=new unsigned int[20]; /*使b指向20個機器字長的數組單元的第一個*/
for(int i=0;i<20;i++)
b[i]=i; /*為這20數組單元賦初值0~19*/
cout << *a <<' '<<b[0]<<' '<<b[19]<<endl;
dt *c=new dt; /* 使c指向一個struct dt數據結構對象的首地址并賦初值1994.8.15*/
c->yy=1994;c->mm=8;c->dd=15;
cout<<c->yy<<'.'<<c->mm<<'.'<<c->dd<<endl;
printf("%Np,%Np,%Np\n",a,b,c); /*顯示a、b、c的地址值*/
delete a;delete []b;
a=new unsigned int[300];
dt *d=new dt;
*d=*c; /*將c的內容復制到d內*/
cout<<d->yy<<'.'<<d->mm<<'.'<<d->dd<<endl;
printf("%Np,%Np,%Np,%Np\n",a, b, c, d); /*顯示a、b、c、d的地址值*/
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -