欢迎来到天天文库
浏览记录
ID:53615456
大小:192.51 KB
页数:51页
时间:2020-04-21
《C语言英文课件Chapter 10.ppt》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、chapter10STRUCTURESANDUNIONSAstructureisacollectionofoneormorevariables,possiblyofdifferenttypes,whicharetreatedasaunitinsteadofasseparateentities.10.1structuredefinition10.2structurevariablescitingandinitialization10.3structurearray10.4structurepointer10.5linkdispoing---applicationofstructure
2、pointer10.6unionandenumeration10.7typedef10.1STRUCTURETYPEANDDECLARATIONOFSTRUCTUREVARIABLESTHESTRUCTURETYPE,INCLANGUAGE,isthecounterpartas“record”inotheradvancedlanguage.一、questionemergingSTUDENTSCORESMANAGETABLECANOTDEALWITH2DARRAYSDIFFERENTTYEPES!1001ZhangXinM2087911002WangLiF2098961003Chen
3、FongM2186901004LiXiaopenM207786numnamesexagescore1score2二、structuretypedeclarationCommonusage:structstructuretypename{datatypemember1;datatypemember2;…………datatypemembern;};structstudent{intnum;charname[20];charsex;intage;floatscore1;floatscore2;};Typenamenumnamesexagescore1score2structstudent
4、demonstration:1、therulestoname“structuretypename”and“membername”,aresamewiththevariables’.2、thedefinitionsofvariablescanbeseperatedorinasamelineliketheinstancebeloweg.structdate{intyear,month,day;};3、thedefinitionsofvariablescouldbebasictypesoranotherstructuretypewhichhasbeendeclarated.eg.thet
5、ype”birthday”intheeg.Ofstructuretypestd_infoisadefinitedstructuretype--date三、STRUCTUREVARIABLESDECLARATIONStructuretype(userdefinition)Standarttype(systemdefinition)1、indirectdeclaration──firstdeclarethestructuretype,thenthestructurevariablesThesameusagestructstudent{intnum;charname[20];charse
6、x;intage;floatscore1;floatscore2;};structstudentstu1,stu2;numnamesexagescore1score2stu12、directdeclaration(1)definitethestructurevariable,whendefinitingthestructuretype;(2)definitethestructurevariabledirectly;(1)structstudent{intnum;charname[20];……floatscore2;}stu1,stu2;(2)struct{intnum;charna
7、me[20];……floatscore2;}stu1,stu2;3、demonstration(1)differstructuretypeandvariable,whicharecompletelydifferentconception,justastypeintandvariableofint(2)membernamesinstructure,maybesameasothervariablesinprogram,standfordifferentobjects[eg
此文档下载收益归作者所有