A sentimental robot

typedef structure 본문

C

typedef structure

GOD03219 2018. 1. 3. 10:11

#include <stdio.h>


typedef int Money;

void main()
{
 Money x,y;

 

 x = 10;
 y = 20;

}


enum : 나열


 


#include <stdio.h>


typedef enum{
 Ri, Di, El
}Day;     //declaration

enum{ jo, euni, bee } x, y;     //definition

void main()
{
 Day a;
 Day b;
 Day c;

 

 a = Ri;
 b = Di;
 c = El;

 

 printf("%d %d %d\n", a,b,c);

 

 x = jo;
 y = bee;

 

 printf("%d %d\n",x,y);

 

}


 union


 


#include <stdio.h>

typedef union{

 int money;
 double gold;

}Salary;

void main()
{
 Salary x;
 Salary y;
 x.money = 100;


 printf("%d\n",x.money);

 x.gold = 1.2;


 printf("%f\n",x.gold);

 

 

}

'C ' 카테고리의 다른 글

sprintf , srand  (0) 2018.01.03
atoi함수  (0) 2018.01.03
함수포인터  (0) 2018.01.03
strdup함수 활용예제  (0) 2018.01.03
strdup함수 만들기  (0) 2018.01.03