1 typedef n n C typedef float REAL

  • Slides: 13
Download presentation

부가 기능 (1) typedef 선언문 n n 이미 존재하는 C 자료형 이름을 다른 이름으로

부가 기능 (1) typedef 선언문 n n 이미 존재하는 C 자료형 이름을 다른 이름으로 사용할 수 있게 함 typedef float REAL; REAL val; // float val; 위 선언문은 float 대신 REAL을 사용할 수 있도록 함 아래의 #define문을 사용하는 것과 효과는 동일하나, #define문은 전 처리기에 의해 처리되고 typedef는 컴파일러에 의해 처리됨 #define REAL float 기타 사용 예 typedef int ARRAY[100]; ARRAY first, second; // int first[100], second[100]; typedef struct { char name[100]; int id. Num; } emp. Record; emp. Record employee[75]; 기초컴퓨터프로그래밍 3

부가 기능 (3) 조건적 전처리기 지시자 n n n #ifdef, #ifndef // 각각 “if

부가 기능 (3) 조건적 전처리기 지시자 n n n #ifdef, #ifndef // 각각 “if defined”, “if not defined”를 의미 일반적으로 중복 선언을 방지하기 위해 사용 일반 양식 사용 예 #ifndef HDR #define HDR contents of HDR #endif #ifndef condition … #else // 생략 가능 … #endif #if SYSTEM == BSD #define HDR “bsd. h” #elif SYSTEM == MSDOS #define HDR “msdos. h” #endif #include HDR 기초컴퓨터프로그래밍 5

명령행 인자 (2) 명령행의 저장 방법 com file 1 file 2 data c o

명령행 인자 (2) 명령행의 저장 방법 com file 1 file 2 data c o m f i l e 1 f i l e 2 d a t a argv[0] argv[1] argv[2] void main(int argc, char *argv[]) { … printf(“n. The value of argc is %dn”, argc); for(i=0; i<argc; i++) printf(“argv[%d]: %sn”, argv[i]); … } 기초컴퓨터프로그래밍 argv[3] 출력 The value of argc is 4 argv[0]: com argv[1]: file 1 argv[2]: file 2 argv[3]: data 13