+ All Categories
Home > Documents > Ch. 1 Digital Computers and...

Ch. 1 Digital Computers and...

Date post: 10-Jun-2020
Category:
Upload: others
View: 0 times
Download: 0 times
Share this document with a friend
19
1 Intelligent Robotics Lab. Dr. Byoung-Ho Kim Professor Electronics, Control and Robotics Lab ., Dept. of Mechatronics Eng., Kyungsung University Office : 8-403, Engineering Building, Tel. : 051-663-4692 E-mail: [email protected] C-Programming
Transcript
Page 1: Ch. 1 Digital Computers and Informationks.ac.kr/kimbh/KSU-Lectures/Lecture2020-1/Ch01-CProgamming_2020.pdf3 Intelligent Robotics Lab. Ch1. C 언어의이해와기본적인개발환경

1

Intelligent Robotics Lab.

Dr. Byoung-Ho Kim

ProfessorElectronics, Control and Robotics Lab.,

Dept. of Mechatronics Eng., Kyungsung University

Office : 8-403, Engineering Building, Tel. : 051-663-4692

E-mail: [email protected]

C-Programming

Page 2: Ch. 1 Digital Computers and Informationks.ac.kr/kimbh/KSU-Lectures/Lecture2020-1/Ch01-CProgamming_2020.pdf3 Intelligent Robotics Lab. Ch1. C 언어의이해와기본적인개발환경

2

Intelligent Robotics Lab.

Introduction

Title : C-Programming

Objectives

C-언어를 이용한 기본적인 프로그래밍 능력 배양

컴퓨터 프로그래밍을 위한 데이터의 표현 방식, 연산자 및 다양한 함수 등

예제를 통한 프로그래밍 실습

Topics : 수업 계획서 C언어의 이해와 기본적인 개발환경

데이터의 표현 방식

연산자

다양한 함수

Page 3: Ch. 1 Digital Computers and Informationks.ac.kr/kimbh/KSU-Lectures/Lecture2020-1/Ch01-CProgamming_2020.pdf3 Intelligent Robotics Lab. Ch1. C 언어의이해와기본적인개발환경

3

Intelligent Robotics Lab.

Ch1. C 언어의 이해와 기본적인 개발환경

Topics and Objectives

C Programming에 대한 전반적인 이해

C 언어와 컴파일러(Compiler)의 관계

소스(Source) 파일, 오브젝트(Object) 파일, 실행(Execute) 파일

C 프로그램 개발환경에 대한 이해

C 프로그램 작성, 컴파일 및 실행하는 방법

Page 4: Ch. 1 Digital Computers and Informationks.ac.kr/kimbh/KSU-Lectures/Lecture2020-1/Ch01-CProgamming_2020.pdf3 Intelligent Robotics Lab. Ch1. C 언어의이해와기본적인개발환경

4

Intelligent Robotics Lab.

C Programming 이해

Example Task

지능로봇 제어

체계화된 명령에 의한 다양한 동작 및 기능 구현

아이로비Q, Yujin Robot

Page 5: Ch. 1 Digital Computers and Informationks.ac.kr/kimbh/KSU-Lectures/Lecture2020-1/Ch01-CProgamming_2020.pdf3 Intelligent Robotics Lab. Ch1. C 언어의이해와기본적인개발환경

5

Intelligent Robotics Lab.

전통적인 실행파일 생성 방법 Assembly 언어로 Program 작성

작성된 Assembly Program Binary Code로 변환

실행파일은 Binary Code의 묶음

Page 6: Ch. 1 Digital Computers and Informationks.ac.kr/kimbh/KSU-Lectures/Lecture2020-1/Ch01-CProgamming_2020.pdf3 Intelligent Robotics Lab. Ch1. C 언어의이해와기본적인개발환경

6

Intelligent Robotics Lab.

Assembly 언어

인간에게 친숙한 언어가 아닌 기계에 친숙한 언어

필요한 하드웨어 지식이 많아 이해하는데 어려움이 따름

구조적 특성상 복잡한 프로그램의 구현이 쉽지 않음

CPU에 따라서 언어 구성이 달라짐

C 언어

인간이 이해하기 쉬운 언어로 구성되어 있고, 필요한 하드웨어의 지식

이 상대적으로 적어서 학습이 쉽다.

구조적 특성상 복잡한 프로그램의 구현이 가능하다.

CPU에 상관 없이 동일한 언어 구성을 지닌다.

Page 7: Ch. 1 Digital Computers and Informationks.ac.kr/kimbh/KSU-Lectures/Lecture2020-1/Ch01-CProgamming_2020.pdf3 Intelligent Robotics Lab. Ch1. C 언어의이해와기본적인개발환경

7

Intelligent Robotics Lab.

Source 파일에서 Execute 파일 생성 방법 Source 파일

C 언어로 작성된 확장자가 C인 파일: running.c

Object 파일

컴파일의 과정을 통해서 생성되는 결과물: running.obj

Execute 파일

링커(linker)라는 프로그램에 의해 최종 생성: running.exe

Page 8: Ch. 1 Digital Computers and Informationks.ac.kr/kimbh/KSU-Lectures/Lecture2020-1/Ch01-CProgamming_2020.pdf3 Intelligent Robotics Lab. Ch1. C 언어의이해와기본적인개발환경

8

Intelligent Robotics Lab.

C 프로그램 개발환경

Step 1: VC++ 설치 Visual C++ Express 2008 Edition : Download @ Microsoft Homepage

Visual Studio Community 2015 Edition

https://visualstudio.microsoft.com/ko/vs/older-downloads/

Step 2: VC++ 실행

Page 9: Ch. 1 Digital Computers and Informationks.ac.kr/kimbh/KSU-Lectures/Lecture2020-1/Ch01-CProgamming_2020.pdf3 Intelligent Robotics Lab. Ch1. C 언어의이해와기본적인개발환경

9

Intelligent Robotics Lab.

Step 3: 솔루션(solution)과 프로젝트(project) 생성 솔루션: 하나 이상의 프로젝트를 담는 장소

프로젝트: 하나 이상의 소스파일을 담는 장소

그림 1-7, 1-8, 1-9, 1-10의 과정 참조

Page 10: Ch. 1 Digital Computers and Informationks.ac.kr/kimbh/KSU-Lectures/Lecture2020-1/Ch01-CProgamming_2020.pdf3 Intelligent Robotics Lab. Ch1. C 언어의이해와기본적인개발환경

10

Intelligent Robotics Lab.

솔루션과 프로젝트 생성: 그림 1-7

파일(file)새로 만들기(new)프로젝트(project)

Page 11: Ch. 1 Digital Computers and Informationks.ac.kr/kimbh/KSU-Lectures/Lecture2020-1/Ch01-CProgamming_2020.pdf3 Intelligent Robotics Lab. Ch1. C 언어의이해와기본적인개발환경

11

Intelligent Robotics Lab.

솔루션과 프로젝트 정보 입력 및 확인: 그림 1-8, 1-9

프로젝트 형식(project types): Win32

템플릿(templates): Win32 콘솔 응용 프로그램

이름(Name): FirstProject

위치(Location): C:\

솔루션 이름: FirstSolution

Page 12: Ch. 1 Digital Computers and Informationks.ac.kr/kimbh/KSU-Lectures/Lecture2020-1/Ch01-CProgamming_2020.pdf3 Intelligent Robotics Lab. Ch1. C 언어의이해와기본적인개발환경

12

Intelligent Robotics Lab.

일부 설정 변경: 그림 1-10

그림 1-9에서 다음 버튼(Next) 선택 그림 1-10

그림 1-10의 추가 옵션(Additional options): √ 빈 프로젝트(Empty project) 선택

Page 13: Ch. 1 Digital Computers and Informationks.ac.kr/kimbh/KSU-Lectures/Lecture2020-1/Ch01-CProgamming_2020.pdf3 Intelligent Robotics Lab. Ch1. C 언어의이해와기본적인개발환경

13

Intelligent Robotics Lab.

솔루션과 프로젝트 생성 완료: 그림 1-11

그림 1-10에서 마침 버튼(Finish) 선택 그림 1-11

Page 14: Ch. 1 Digital Computers and Informationks.ac.kr/kimbh/KSU-Lectures/Lecture2020-1/Ch01-CProgamming_2020.pdf3 Intelligent Robotics Lab. Ch1. C 언어의이해와기본적인개발환경

14

Intelligent Robotics Lab.

Step 4: 소스(Source) 파일 생성 그림 1-12, 1-13, 1-14 과정 참조

소스 파일 추가를 위한 새 항목 선택: 그림 1-12

소스 파일(Source Files) 위에서 마우스 오른쪽 버튼 클릭추가(Add)새항목(New Item)

Page 15: Ch. 1 Digital Computers and Informationks.ac.kr/kimbh/KSU-Lectures/Lecture2020-1/Ch01-CProgamming_2020.pdf3 Intelligent Robotics Lab. Ch1. C 언어의이해와기본적인개발환경

15

Intelligent Robotics Lab.

소스 파일 추가를 위한 입력 화면 및 선택 내용: 그림 1-13, 1-14

범주(Categories): 코드(Code)

템플릿(templates): C++ 파일

이름(Name): first.c

Page 16: Ch. 1 Digital Computers and Informationks.ac.kr/kimbh/KSU-Lectures/Lecture2020-1/Ch01-CProgamming_2020.pdf3 Intelligent Robotics Lab. Ch1. C 언어의이해와기본적인개발환경

16

Intelligent Robotics Lab.

소스 파일 추가 완료: 그림 1-15

그림 1-14에서 추가 버튼(Add) 선택 그림 1-15

Page 17: Ch. 1 Digital Computers and Informationks.ac.kr/kimbh/KSU-Lectures/Lecture2020-1/Ch01-CProgamming_2020.pdf3 Intelligent Robotics Lab. Ch1. C 언어의이해와기본적인개발환경

17

Intelligent Robotics Lab.

Step 5: C 프로그램 작성 예제 first.c 프로그램 작성: p. 16

#include <stdio.h>

int main(void)

{

printf("C 프로그래밍\n");

return 0;

}

Page 18: Ch. 1 Digital Computers and Informationks.ac.kr/kimbh/KSU-Lectures/Lecture2020-1/Ch01-CProgamming_2020.pdf3 Intelligent Robotics Lab. Ch1. C 언어의이해와기본적인개발환경

18

Intelligent Robotics Lab.

Step 6: 실행 파일 생성 실행 파일 생성을 위해서는 컴파일 및 링킹 과정이 필요한데, VC++

Express Edition에서는 ‘빌드(Build)’ 기능 이용

실행 파일의 생성 및 빌드 결과: 그림 1-16, 1-17

C:\FirstSolution\debug\FirstProject.exe

Page 19: Ch. 1 Digital Computers and Informationks.ac.kr/kimbh/KSU-Lectures/Lecture2020-1/Ch01-CProgamming_2020.pdf3 Intelligent Robotics Lab. Ch1. C 언어의이해와기본적인개발환경

19

Intelligent Robotics Lab.

Step 7: 프로그램 실행 및 결과 확인 실행 파일 클릭: C:\FirstSolution\debug\FirstProject.exe

프로그램 실행 방법: 그림 1-18

디버그(Debug) 디버깅 하지 않고 시작(Start Without Debugging) 그림 1-19


Recommended