일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
- 부주상골증후군
- 코테
- ChatGPT
- 독일어
- SWIFT
- 카카오인턴
- 분할정복
- 롯데정보통신
- IOS
- 카카오코테
- 세브란스
- 독일어독학
- 카카오인턴십
- 백준
- 독학
- 스택
- 부주상골수술
- BFS
- 리눅스
- sql
- istringstream
- 프로그래머스
- 부주상골
- dp
- DFS
- 부주상골수술후기
- SQLD
- c++
- 구현
- 코딩테스트
- Today
- Total
슈뢰딩거의 고등어
Difference between typedef struct & struct 본문
how to define Struct?
struct SuperMan {
int power;
int age;
};
We can define a Struct named SuperMan like this. But, actually, this doesn't create struct SuperMan itself. It just lets Compiler know how struct SuperMan looks like.
If you want to define a Struct variable that has real memory, you should define it like this.
struct SuperMan ClarkKent;
OR you can make it shorter.
struct SuperMan {
int power;
int age;
}ClarkKent;
AS you know, defining struct means creating a new data type.
Defining struct variable means giving it to the new memory space.
WHAT is typedef??
typedef gives a nametag to a certain data type.
For example, there is a data type named unsigned short int. Typing it every time is exhausting or may cause errors. What if it has another short nickname? So we can give it a nickname like UINT16.
typedef unsigned short int UINT16;
WHAT is typedef struct??
typedef + [type] + [nickname]
typedef struct SuperMan {
int power;
int age;
} sman_t;
[type] : struct SuperMan {}
[nickname] : sman_t;
Therefore, We can call defining struct SuperMan to sman_t;
Now we can define a variable like
sman_t ClarkKent;
So why we use typedef struct is We can make it shorter.
'tech' 카테고리의 다른 글
데이터 단위 KB, MB, GB, TB, PB (0) | 2022.01.15 |
---|---|
컴퓨터의 기본 원리 및 각 부품의 역할 (CPU, RAM, HDD/ SSD, VGA) (0) | 2022.01.15 |
키크론 k3 레트로 후기 (적축) (0) | 2022.01.13 |
python, rpm package download (offline settings) (0) | 2021.12.02 |
linux setting (0) | 2021.12.02 |