13
.
: , ++ .
.
,
: (structure), (union), (enumeration), (bitfields). - typedef () .
, . . . , .
: ; ; ; . .;
ANSI :
1. , ;
2. ;
3. ;
, :
4. &; ( );
5. . >;
6. , auto.
(.. ).
, , , , . , . , . .
. . , , , ..
:
Struct _
{
_1 _1;// ,
...
_N _N;
};
_ variable; //
struct , . . , , . :
|
|
struct _
{
_1 _1; //
...
_N _N; //
} variable; //
_ , .
, . . , , , , .. :
struct stydent
{
char name[20],cvet_gl[15];
int rost,ves, god_roj;
float raz_ob;
};
student styd;
(stud1) , :
std. name 20 ;
std. rost, ctd.ves std.god_roj ;
std.raz_ob
std.cvet_gl 15 .
( , ) .
, :
strcpy(std. Name, );
std. rost = 173;
std.ves = 68;
std.raz_ob = 23,5;
strcpy(std.cvet_gl,);
std.god_roj = 1986;
, , .
, .
:
#include <stdlib.h>
#include <iostream.h>
#include <string.h>
typedef char stringa[20];
struct stydent
{
stringa name,cvet_gl;
int rost,ves, god_roj;
float raz_ob;
};
stydent styd;
int main()
{
strcpy(styd.name,"IBAHOB");
styd. rost = 173;
styd.ves = 68;
styd.raz_ob = 27;
strcpy(styd.cvet_gl,"KARIE");
styd.god_roj = 1986;
system("echo :");
cout<<"Name "<<styd.name<<endl;
cout<<"GLAZA "<<styd.cvet_gl<<endl;
cout<<"POCT "<<styd.rost<<endl;
cout<<"BEC "<<styd.ves<<endl;
cout<<"GOD POJDEHIJ "<<styd.god_roj<<endl;
cout<<"PAZMEP OBYBI "<<styd.raz_ob<<endl;
system("PAUSE");
return 0;
}
:
:
Name IBAHOB
GLAZA KARIE
POCT 173
BEC 68
GOD POJDEHIJ 1986
PAZMEP OBYBI 27
...
.
:
1. | 2_ : ... , ( , , , , , ). , . |
2. | 2_ 1, , . |
3. | 2_ 1, . |
4. | 2_ 1, , . |
5. | 2_ 1, , . |
6. | 2_ 1, , . |
7. | 2_ 1, , . |
8. | 2_ 1, , . |
9. | : ... (, , ), (, , ), , . , . |
10. | 9, , 18 60 . |
11. | 9, , 30 . |
12. | 9 , 7 . |
13. | 9 , 18 27 |
14. | 9, , 1 5 . |
15. | 9, , 50 . |
|
|