- 구조체를 선언할 때 typedef를 사용하면 별칭이 꼭 필요하고, 이때는 구조체를 사용할때 별칭만으로 선언 가능하다.
#include <stdio.h>
struct A {
int a;
int b;
int c;
};
typedef struct {
int a;
int b;
}b;
typedef struct C {
int a;
int b;
}c;
/* 안되는 선언 - typedef로 선언했으면 별칭이 있어야 함*/
typedef struct D{
int a;
int b;
}(별칭);
typedef struct A a;
int main (void)
{
a a1;
struct A a2;
b b1;
c c1;
}
'Computer Science > Algorithm' 카테고리의 다른 글
Merge Sort (병합 정렬) (0) | 2020.09.03 |
---|---|
[배열과 포인터] 일차원 배열과 이차원 배열 및 포인터 표기 방법 (0) | 2020.09.01 |
Insertion sort(삽입 정렬) (0) | 2020.08.31 |
Selection sort(선택 정렬) (0) | 2020.08.31 |
Bubble sort(버블소트) (0) | 2020.08.31 |