資源簡介
C++實戰源碼-指向結構體變量的指針(入門級實例102).zip
代碼片段和文件信息
//?Pointer.cpp?:?Defines?the?entry?point?for?the?console?application.
//
#include?“stdafx.h“
#include?“iostream.h“
#include?
struct?student
{
int?num; //學生學號
char?name[10]; //學生姓名
char?sex; //學生性別
int?age; //學生年齡
float?score; //學生成績
};
int?main()
{
???struct?student?student1={1001“小李“‘M‘2092.5}; //定義結構體變量
???struct?student?*p; //定義指針變量指向結構體類型
???p=&student1; //使指針指向結構體變量
???printf(“學號:%d\n“p->num); //輸出學生學號
???printf(“姓名:%s\n“p->name); //輸出學生姓名
???printf(“性別:%c\n“p->sex); //輸出學生性別
???printf(“年齡:%d\n“p->age); //輸出學生年齡
???printf(“成績:%f\n“p->score); //輸出學生成績
???getch();
???return?0;
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????????835??2010-10-20?09:04??Pointer\Pointer.cpp
?????文件????????4548??2010-10-20?08:46??Pointer\Pointer.dsp
?????文件?????????539??2010-10-20?08:46??Pointer\Pointer.dsw
?????文件?????????294??2010-10-20?08:46??Pointer\StdAfx.cpp
?????文件?????????769??2010-10-20?08:46??Pointer\StdAfx.h
- 上一篇:C++實戰源碼-將二維數組行列對換
- 下一篇:C++實戰源碼-修改可執行文件中的資源
評論
共有 條評論