欢迎来到天天文库
浏览记录
ID:58386606
大小:192.50 KB
页数:51页
时间:2020-09-07
《C语言英文课件Chapter.ppt》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、chapter10STRUCTURESANDUNIONSAstructureisacollectionofoneormorevariables,possiblyofdifferenttypes,whicharetreatedasaunitinsteadofasseparateentities.10.1structuredefinition10.2structurevariablescitingandinitialization10.3structurearray10.4structurepointe
2、r10.5linkdispoing---applicationofstructurepointer10.6unionandenumeration10.7typedef10.1STRUCTURETYPEANDDECLARATIONOFSTRUCTUREVARIABLESTHESTRUCTURETYPE,INCLANGUAGE,isthecounterpartas“record”inotheradvancedlanguage.一、questionemergingSTUDENTSCORESMANAGETA
3、BLECANOTDEALWITH2DARRAYSDIFFERENTTYEPES!1001ZhangXinM2087911002WangLiF2098961003ChenFongM2186901004LiXiaopenM207786numnamesexagescore1score2二、structuretypedeclarationCommonusage:structstructuretypename{datatypemember1;datatypemember2;…………datatypemembe
4、rn;};structstudent{intnum;charname[20];charsex;intage;floatscore1;floatscore2;};Typenamenumnamesexagescore1score2structstudentdemonstration:1、therulestoname“structuretypename”and“membername”,aresamewiththevariables’.2、thedefinitionsofvariablescanbesepe
5、ratedorinasamelineliketheinstancebeloweg.structdate{intyear,month,day;};3、thedefinitionsofvariablescouldbebasictypesoranotherstructuretypewhichhasbeendeclarated.eg.thetype”birthday”intheeg.Ofstructuretypestd_infoisadefinitedstructuretype--date三、STRUCTU
6、REVARIABLESDECLARATIONStructuretype(userdefinition)Standarttype(systemdefinition)1、indirectdeclaration──firstdeclarethestructuretype,thenthestructurevariablesThesameusagestructstudent{intnum;charname[20];charsex;intage;floatscore1;floatscore2;};structs
7、tudentstu1,stu2;numnamesexagescore1score2stu12、directdeclaration(1)definitethestructurevariable,whendefinitingthestructuretype;(2)definitethestructurevariabledirectly;(1)structstudent{intnum;charname[20];……floatscore2;}stu1,stu2;(2)struct{intnum;charna
8、me[20];……floatscore2;}stu1,stu2;3、demonstration(1)differstructuretypeandvariable,whicharecompletelydifferentconception,justastypeintandvariableofint(2)membernamesinstructure,maybesameasothervariablesinprogram,standfordifferentobjects[eg
此文档下载收益归作者所有