일반적으로 사용하는 구조체 초기화 방법은 아래와 같다.
위의 방법은 C89 의 방법이고
C99에서는 아래와 같이 특정변수만 제한적으로 초기화가 가능하다.
[링크 : http://publib.boulder.ibm.com/infocenter/lnxpcomp/v8v101/index.jsp?topic]
struct address {
int street_no;
char *street_name;
char *city;
char *prov;
char *postal_code;
};
struct address temp_address =
{ 0,
"st. green",
"Hamilton",
"Ontario",
"123-456");
위의 방법은 C89 의 방법이고
C99에서는 아래와 같이 특정변수만 제한적으로 초기화가 가능하다.
struct address {
int street_no;
char *street_name;
char *city;
char *prov;
char *postal_code;
};
struct address temp_address =
{ .city = "Hamilton", .prov = "Ontario" };[링크 : http://publib.boulder.ibm.com/infocenter/lnxpcomp/v8v101/index.jsp?topic]
'Programming > C Win32 MFC' 카테고리의 다른 글
| MFC 프로젝트에서 RichEditCtrl 사용하기 - 왜 프로그램이 안떠? (2) | 2009.06.12 |
|---|---|
| indent style (0) | 2009.06.09 |
| binutils - ar, nm, objdump (0) | 2009.05.26 |
| 신기한 코드 사이즈 (0) | 2009.05.19 |
| double형을 int 형으로 출력하면? (0) | 2009.05.15 |