-
大小: 2.81KB文件類型: .zip金幣: 1下載: 0 次發(fā)布日期: 2021-02-21
- 語言: C/C++
- 標簽:
資源簡介
C++實戰(zhàn)源碼-用new動態(tài)創(chuàng)建結(jié)構(gòu)體(入門級實例087).zip
代碼片段和文件信息
//?new.cpp?:?Defines?the?entry?point?for?the?console?application.
//
#include?“stdafx.h“
#include?“iostream.h“
//人員信息
struct?Person
{
char?ID[6];//編號
char?Name[10];//姓名
};
int?main(int?argc?char*?argv[])
{
int?len?=?3;//總?cè)藬?shù)
int?structinfo[10];//存信息的數(shù)組
for?(int?i?=?0;i {
Person?*p?=?new?Person;//動態(tài)創(chuàng)建結(jié)構(gòu)變量
structinfo[i]?=?(int)p;//存入數(shù)組
cout?<“請輸入第“?< cin?>>?p->ID;
cout?<“請輸入第“?< cin?>>?p->Name;
}
for?(?i?=?0;?i {
Person?*p?=?(Person?*)structinfo[i];//取出變量
cout?<“第“?<ID?<“\n“;
cout?<“第“?<Name?<“\n“;
delete?[]?p;
}
return?0;
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????????794??2010-09-25?13:35??new\new.cpp
?????文件????????4500??2010-09-25?13:20??new\new.dsp
?????文件?????????531??2010-09-25?13:20??new\new.dsw
?????文件?????????290??2010-09-25?13:20??new\StdAfx.cpp
?????文件?????????769??2010-09-25?13:20??new\StdAfx.h
評論
共有 條評論