본문 바로가기
IT/C언어

<C언어> 역사, 탄생 배경 등 정리 -기본편 1

by 세계 최고의 AI Engineer_naknak 2023. 3. 21.
 
파이팅 해야지 (Feat. 이영지)
아티스트
부석순 (SEVENTEEN)
앨범
부석순 1st Single Album 'SECOND WIND'
발매일
2023.02.06

This poster is to study C for myself.

And I post it in English for study too.

 

Briefly, this post is dealing with basic of C language.

(For example value, array, pointer etc...)

Later if I recognize there is things what I miss, I'm gonna update it!

 

Okay, Let's go.

And here is a reference.

http://www.tcpschool.com/c/c_intro_basic

 

코딩교육 티씨피스쿨

4차산업혁명, 코딩교육, 소프트웨어교육, 코딩기초, SW코딩, 기초코딩부터 자바 파이썬 등

tcpschool.com


What is C?
Before start, We should know what is C.

C is procedure-oriented programming language which is having features of low-level language and high-level language.

And you can find the meaning of each words in the reference.

 

 

Then let's see the history of C!

C is a general advanced language which is made for using it on UNIX OS by Kenneth Thompson and Dennis Ritchie of Bell Laboratory in 1972.

From ALGOL 60, which is called A language, through CPL, BCPL, Kenneth Thompson developed Language B.

After, Dennis Ritchie makes more improvements on Language B, he makes Language C.

The name of C stem from B, because C is developed right after B.

 

Background of the Birth of Language C

Before C, UNIX OS have used assembly language which is low-level language.

But assembly language depends on certain hardware, a program which is written in this language can't port to a different hardware.

Namely, they should write a program which is doing one function more than one times as much as kind of CPU.

According to it, it's necessary that a language which is more easier than assembly language and good at porting.

So, Language C is developed.

 

Feature of C

Advantage

1. Good at porting, a program written in C can be ported to various hardwares.

2. C has feature of low-level language, C could control hardware at the level of assembly.

 

Disadvantage

1. C언어는 저급 언어의 특징을 가지고 있으므로, 자바와 같은 다른 고급 언어보다 배우기가 쉽지 않습니다.

1. C has feature of low-level language, is not easy to learn than Java which is kind of different high-level language. (((check grammar)))

2. C언어는 다른 언어와는 달리 시스템 자원을 직접 제어할 수 있으므로, 프로그래밍하는데 세심한 주의를 기울여야 합니다.

2. C controls system resource not likely other languages, you must pay careful attention to programming. 

 

 

C programming

프로그래밍이란 목적에 맞는 알고리즘으로부터 프로그래밍 언어를 사용하여 구체적인 프로그램을 작성하는 과정을 의미합니다.

The meaning of programing is a process that write specific program using program languages from purposeful(목적에 맞는) argorithm.

And this program must be chaged to executable file before it is executed.

So, how does C make executable file?

Let's see the process.

 

1. Writing source file

2. Preprocess by Preprocessor

3. Compile by Compiler

4. Link by Linker 

5. Creation of executable file

 

선행처리기(preprocessor)에 의한 선행처리

선행처리(preprocess)란 소스 파일 중에서도 선행처리 문자(#)로 시작하는 선행처리 지시문의 처리 작업을 의미합니다.

이러한 선행처리 작업은 선행처리기(preprocessor)가 수행합니다.

선행처리기는 코드를 생성하는 것이 아닌, 컴파일하기 전 컴파일러가 작업하기 좋도록 소스를 재구성해주는 역할만을 합니다.

 

Summary, before compiler compiles source codes, preprocessor restructures the source codes for compiler to work better.

 

컴파일러(compiler)에 의한 컴파일

컴퓨터는 0과 1로 이루어진 이진수로 작성된 기계어만을 이해할 수 있습니다.

소스 파일은 개발자에 의해 C언어로 작성되므로, 컴퓨터는 그것을 바로 이해할 수 없습니다.

따라서 소스 파일을 컴퓨터가 알아볼 수 있는 기계어로 변환시켜야 하는데, 그 작업을 컴파일(compile)이라고 합니다.

Computer doesn't understand the source code, therefore it needs to be chaged as machine language which is computer can understand. And we call this working as compile.

 

컴파일은 컴파일러에 의해 수행되며, 컴파일이 끝나 기계어로 변환된 파일을 오브젝트 파일(object file)이라고 합니다.

이러한 오브젝트 파일의 확장자는 .o 나 .obj 가 됩니다.

After compiling, the file which is consist of machine language is called as object file. These object files have extension of .o or .obj.

 

링커(linker)에 의한 링크

컴파일러에 의해 생성된 오브젝트 파일은 운영체제와의 인터페이스를 담당하는 시동 코드(start-up code)를 가지고 있지 않습니다.

(*시동 코드 :  프로그램과 운영체제 사이의 인터페이스를 담당한다.

->ex)window와 linux 모두 같은 하드웨어에서 운영되므로 동일한 오브젝트 코드가 두운영체제에서 모두 동작하나 두운영체제는 프로그램을 처리하는 방식이 다르기 때문에 각자에게 맞는 시동코드가 필요하다.)

 

 

또한, 대부분의 C 프로그램에서 사용하는 C 표준 라이브러리 파일도 포함되어 있지 않습니다.

이때 하나 이상의 오브젝트 파일과 라이브러리 파일, 시동 코드 등을 합쳐 하나의 파일로 만드는 작업을 링크(link)라고 합니다. 링크는 링커(linker)에 의해 수행되며, 링크가 끝나면 하나의 새로운 실행 파일이나 라이브러리 파일이 생성됩니다.

이처럼 여러 개의 소스 파일을 작성하여 최종적으로 링크를 통해 하나의 실행 파일로 만드는 것을 분할 컴파일이라고 합니다.

After link working, new executable file or library file is created.

 

실행 파일(executable file)의 생성

소스 파일은 선행처리기, 컴파일러 그리고 링커에 의해 위와 같은 과정을 거쳐 실행 파일로 변환됩니다.

최근 사용되는 개발 툴은 대부분 위에서 소개한 선행처리기, 컴파일러, 링커를 모두 내장하고 있으므로, 소스 파일에서 한 번에 실행 파일을 생성해 줍니다.

이렇게 생성된 실행 파일의 확장자는 .exe 가 됩니다.

 

 

The features of C Programming
The structure of C program
#include <stdio.h>

#define TEXT "Welcome to C Programming!!"  

int main()

{

    printf(TEXT);

    return 0;

}

This is example of structure of C program.

 

 

General features of C program

C언어로 작성된 프로그램이 가지는 일반적인 특징은 다음과 같습니다.

A program which is writen in C has general features like below .

 

1. C 프로그램의 기본 단위는 함수입니다.

    C언어로 구현되는 모든 프로그램은 반드시 main() 함수를 가지고 있어야 합니다.

2. 함수 내의 각 명령문은 세미콜론(;)으로 끝나야 합니다.

printf("C언어"); // 정상적으로 출력됨.

printf("C언어")  // 오류가 발생함.

3. C언어는 대소문자를 구분합니다.

printf("C언어"); // 정상적으로 출력됨.

Printf("C언어")  // 오류가 발생함.

4. C언어는 자유 형식(free-format)을 허용합니다.

int func() { printf("C언어는 재밌어요!"); }

int func()

{

    printf("C언어는 재밌어요!");

}

*But for the readability of the code, second code is recommended.

 

To add to this, you can annotate like below.

// 한 줄 주석

/* 여러

   줄

   주석 */

 

Next time, I'm gonna post about basic grammar of C!

See you later!

'IT > C언어' 카테고리의 다른 글

C언어 <변수>  (0) 2023.01.16
C, 세상에서 가장 아름다운 언어  (0) 2023.01.12

댓글