• 검색 결과가 없습니다.

전기전자 프로그래밍 실습

N/A
N/A
Protected

Academic year: 2022

Share "전기전자 프로그래밍 실습"

Copied!
26
0
0

로드 중.... (전체 텍스트 보기)

전체 글

(1)

전기전자 프로그래밍 실습

Lecture #1

Jaewoong Kim (create@skku.edu) Ph.D Candidates

Nano & Intelligent System Lab(NIS Lab), Intelligent Systems Research Institute(ISRI),

Electrical and Computer Engineering

@Sungkyunkwan University

2013/03

(2)

General definition of C language

in textbook

(3)

• 궁금하면 가보세요…

• http://ko.wikipedia.org/wiki/C_%28%ED%94%84%EB%

A1%9C%EA%B7%B8%EB%9E%98%EB%B0%8D_%EC

%96%B8%EC%96%B4%29

• http://www.winapi.co.kr/clec/cpp1/1-2-1.htm

General definition of C language in textbook

C언어의 역사

(4)

General definition of C language in textbook

프로그램 생성의 구조

컴파일 링크 실행

일종의 번역기로 Source Code를 기계어로 변환시킴

Object 파일 또는 중간파일 .OBJ 파일을 링커를 통해 실행(exe) 파일로 변환 (보안,호환, 컴파일 시간 절약)

각종 Library 각종 Library

+

(5)

General definition of C language in textbook

확인

(6)

main()

– 프로그램의 동작

(7)

#include "stdafx.h“

int _tmain(int argc, _TCHAR* argv[]) {

return 0;

}

main()

main 함수

#include <stdio.h>

int main(int argc, char* argv[]) {

return 0;

}

main 함수의 엄격함이 파괴되기 시작했고 그 중심에 Microsoft(이하 MS)가 있다.

MS의 노력에 많은 개발자들이 고마워했다.

하지만 개발자들은 점점 MS의 편안함에 노예가 되어가게 되고 ANSI C와의 차이점이 생겨나기 시작했다.

결국 ANSI를 지켜가는 Linux와 Window 두 가지 프로그램 룰이 생겨났다.

싸움이야 어찌되었든 둘은 같은 의미를 지닌다.

(8)

• 호환성의 목적

• 일종의 표준화

• 미국 규격 협회(American National Standards Institute, ANSI)

main()

ANSI 란?

[Reference]

- http://c-faq.com/ansi/index.html (원문)

- http://www.dal.kr/chair/cdata/cfaq_kr/node15.html (번역문)

(9)

• int main();

• int main(void);

• int main(int argc, char *argv[]);

main()

ANSI 에서 정한 표준 main 함수

(10)

• See program example

– main 함수의 return 유/무 – main 함수의 return type

– main 함수의 입력 argument 유/무 – main 함수의 입력 argument type – main 함수의 입력 argument alias

main()

main 함수의 다양함

(11)

#- Preprocessor(전처리기)

(12)

#- Preprocessor(전처리기)

example

(13)

#- Preprocessor(전처리기)

example

(14)

#- Preprocessor(전처리기)

example

(15)

• 컴파일 이전에 미리 처리되는 문장(=선행 처리기)

#- Preprocessor(전처리기)

Definition

- 파일 처리를 위한 전처리문 : #include

- 형태 정의를 위한 전처리문 : #define, #undef

- 조건 처리를 위한 전처리문 : #if, #ifdef, #ifndef, #else, #elif, #endif - 에러 처리를 위한 전처리문 : #error

- 디버깅을 위한 전처리문 : #line

- 컴파일 옵션 처리를 위한 전처리문 : #pragma - 파일 처리를 위한 전처리문 : #include

- 형태 정의를 위한 전처리문 : #define, #undef

- 조건 처리를 위한 전처리문 : #if, #ifdef, #ifndef, #else, #elif, #endif - 에러 처리를 위한 전처리문 : #error

- 디버깅을 위한 전처리문 : #line

- 컴파일 옵션 처리를 위한 전처리문 : #pragma

[Reference]

- http://kaludin.egloos.com/2420699 (more detail)

(16)

#include <stdio.h>

(17)

#include <stdio.h>

In general

[Reference]

- http://ko.wikipedia.org/wiki/Stdio.h (more detail)

stdio.h은 Standard Input/Output library (표준 입출력 라이브러리)의

약어로써, C 언어의 표준 라이브러리 함수의 매크로 정의, 상수, 여러 형의 입출력 함수가 포함된 헤더 파일이다. 1970년대, 벨 연구소의……

대표함수: printf, scanf, fread, fopen….

(18)

#include <stdio.h>

Include의 두 가지 형태

User header include System header include

(19)

#include <stdio.h>

MS 표준라이브러리 함수 저장소

(20)

Argument

(21)

Argument

Argument ?

Argument Vector에 들어갈 문자열들 실행 파일

(22)

Argument

Source

Argument Counter

Argument Vector

(23)

Argument

두 가지 방법(1)

Project -> Properties

Configuration Properties ->

Debugging ->

Command Arguments

(24)

Argument

두 가지 방법(2)

실행파일이 있는

해당 디렉토리로 이동 Control + R ->

cmd 입력

(25)

Argument

두 가지 방법(2)

이동 후 위 와 같이 Command 입력

(26)

QnA

참조

관련 문서