บทที่ 8 -8.2

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

8.

2 (declaration of a structure data type)


struct

1
struct struct_name
{
type1 name1;
type2 name2;
..
typeN nameN;
} struct_var;
2
struct struct_name
{
type1 name1;
type2 name2;
..
typeN nameN;
};
struct struct_name struct_var;

struct
struct_name

struct_var
type1 name1, type2 name2,,typeN nameN 1, 2, 3, ,
N name1, name2,,nameN element 1, element 2, , element
N

8.2
1)
struct employee
{
char emp_name[30];
char position[30];
int salary;
} person;

struct employee
{
char emp_name[30];
char position[30];
int salary;
};
struct employee person;

( 8.1 )
8.1 employee
2)
struct y
{
int a;
char b;
float c;
} x;

struct y
{
int a;
char b;
float c;
};
struct y x;

You might also like