본문 바로가기
학습/IT

[IT] C언어 입문(1) Introduction - C언어의 역사와 기본 개념

by 개성공장 2021. 8. 16.
반응형

□ The basics of C Programming Language

 * Programming Languages

 - Communication method between human and computers

 - Low-level programming languages : Assembly, Machine-oriented

 - High-level programming languages : C, Java, Basic, Pascal, Human-oriented

 

 * History of C

 - 1972 : Dennis Ritchie designed C, PDP-11 computer, AT&T Bell Lab

 - 1973 : Most of the Unix kernel was rewritten in C (예전에는 Assembly로 쓰여졌음)

 - 1978 : "The C Programming Language" was published

 - 1989 : ANSI ratified C (C89)

 - 1990 : ANSI C standard adopted by ISO (C90)

 - 1999 : C99 standard

 - 2007 : work began on a new C standard called C1X

 

 * Features of C language

 : 간결성, 이식성, 효율성

 - Facilities for structured programming, lexical variable scope and recursion

 - Heterogeneous aggregate data type : struct

 - Function parameter passing method : call-by-value

  Call-by-reference is simulated by explicitly passing pointer values

 - Free-format source text : semicolon(;) as a statement terminator

 - Low-level access to computer memory : pointers

 

 * Comparison of C with other languages

 - More recent derivatives : C++, Objective C, C#

 - Influenced : Java, Perl, Python

 - C lacks: exceptions, range/checking, garbage collection, object-oriented programming, Polymorphism

 - Low-level language faster code

 

 * Development cases using C

 - System programming : Operating systems(OS, kernel ...), Embedded system applications

 - Compilers, libraries and interpreters of other programming languages

 : Python(CPython), Perl 5, and PHP are written in C

 - Implementatons of algorithms and data structures

 : GNU Scientific library, Mathematica and MATLAB are completely or partially written in C

 - Intermediate language by implementations of other languages

 : BitC, C++, Eiffel, etc.

 - End-user applications

 

 

 

 Development Process

 * Flow of operations : C Program execution procedure

 - Edit source program (Code text)

 - Compile

 - (debugging)

 - Link & Load

 - Execute

 

 * Source Program

 - 프로그램 소스는 text 파일로 저장됨

 - 텍스트 문자는 모두 ASCII 코드를 이용하여 표현됨

 

 * The Compilation System

 - unix의 경우 gcc라는 컴파일 프로그램 사용

 - 컴파일러는 일련의 과정을 거쳐 source file를 an executable object file로 번역

 * 4개의 compilation phases

 - Pre-processing : reads the system header file (stdio.h) and insert it into the text

 - Compilation : tanslates the text file 'hello.c' into the text file 'hello.s'

 - Assembly : translates 'hello.s' into a relocatable object file 'hello.o'

 - Link : merge the precompiled object file (printf.o)(a part of standard C library) with hello.o program and creates an executable object file (hello)

 

 * Run the Program

 - To run the executable on a unix system, type its name to an application program known as a shell

 $ /hello

 hello, world

 $

 - Shell : 사용자가 내린 명령을 해석하는 interpreter (유닉스 혹은 리눅스 환경)

 

 

 Text Editor in UNIX

 * Introduction to Vim (vi의 변종 중 하나)

 - quick start of vi

 1. vi {file_name}

 2. Press i and type whatever you want

 3. Press <ESC> and type ":wq" to save the contents

 4. cat {file_name}

 5. See the result of step 4

 

 * vi modes

 - Command mode (default, 다른 모드에서 ESC를 누르면)

 : for using vi functions

 - Insert mode (i를 누르면)

 : for text editing

 - Ex-command mode (enter를 누르면)

 : the commands start with ':' and end with 'Enter' key

 

 * Summary of vi commands

 - h, j, k, l : 방향키 대용

 - add text : i (insert), a (append)

 - :wq (write, quit), :q! (don't write, quit), u (undo),

 - delete text : x, X (character), dd (line)

 - search for text : /'Text' (아래방향), ?'Text' (윗방향)

 

 

 Structure of programs

preprocessor directives

int main(void)
{
	declarations;
	statements;
}

 - 대문자, 소문자 구분에 유의

 - C program contains : set of statements, "main" function

 

 

#include <stdio.h>

int main(int argc, char **argv)  // 프로그램에서 인자를 전달하기 위한 것으로 요즘 프로그램에서는 사용 X
{
	printf("Hello, world\n");
	return 0;
}

 - #include <stdio.h> : 시스템에 저장되어 있는 stdio.h를 찾아 include 하라는 뜻 (printf 등의 함수의 library 헤더파일)

 - 주석 : /* ... */,   //

 

 

 * Comments

/************************************
 **           this is a comment             **
*************************************/
 // comment

 

 

※ C언어 입문 시리즈
1. Introduction - C언어의 역사와 기본 개념
2. Variables - 변수, 대입연산자, 구문규칙, 데이터타입 등
3. Data types, 데이터 타입(자료형)
4. Operators, 연산자 - scanf, 산술연산자, 관계연산자, 증감연산자, 대입연산자, 동등연산자 등
5. Operators, 연산자 - 논리연산자, 단축평가, 대입연산자, if문 및 while문 활용
6. Control flow, 제어흐름 - While문, For문, If문, do-while문 등 루프문
7. Function, 함수 - Goto문, getchar와 putchar, 함수 정의와 프로토타입 선언
8. Scope rules/recursion, 변수의 영역규칙과 재귀호출, 난수생성 예시
9. Array와 Pointers, 배열과 포인터
10. Pointer, 역참조, swap 함수 활용, 배열과 포인터 비교
11. File operation 파일연산, String, 다차원 배열 예시
12. structure, union, enumerated types - 구조체, 공용체, 열거체
13. 자료구조(data structure) 예시 - 연결리스트(linked list)
14. C 전처리기(C preprocessor), 함수 포인터(function pointer)

 

반응형

댓글