C언어
-
Hello World 에서 벌어지는 일C언어 2020. 2. 6. 18:44
다음 자료는 C로 작성한 첫번째 프로그램이다. 가장 상단의 #include는 영어로 '포함시키다' 라는 뜻을 내포하고 있다. 즉 stdio.h 라는 파일을 해당 프로그램에 포함시키겠다는 의미이다. 그렇다면 stdio.h 은 무엇이기에 포함을 시키는 것일까 ? C에서 파일은 크게 2가지 형태로 나뉘어 진다. 1. 소스코드 (헤더파일) : 선언에 관한 내용이 기술 되어 있음 즉 사용자가 printf 라는 함수를 사용하기 위해서는 어디선가 해당 함수를 불어와야 하는데 이때 printf라는 함수가 선언되어 있는 파일이 stdio.h 라는 헤더파일이다. 따라서 다음과 같이 stdio.h라는 헤더파일을 포함시킨다고 정의하였다면 stdio.h라는 파일과 사용자가 작성한 소스코드가 같이 컴파일 되어 목적코드로 변환된다..
-
CPU가 메모리를 관리하는 원리C언어 2020. 2. 5. 22:53
전에 포스팅 한 글에 다음과 같은 내용이 있다. " 정보를 처리할 때 CPU의 연산을 통해 정보가 처리되며 해당 과정은 메모리라는 공간을 통해 정보가 전달, 연산, 저장 등의 처리가 이루어진다. " 따라서 정보의 연산과정에서 CPU와 메인 메모리 ( RAM ) 사이에는 매우 많은 정보 전달 과정이 존재하며 CPU는 메인 메모리를 관리하는 역할도 수행한다. 이번 포스트에서는 그렇다면 CPU는 메인 메모리를 도대체 어떠한 원리로 관리를 하게 되는 것인가 ? 다음과 같은 주제에 대해서 다룰 것이다. 위의 그림은 메모리를 그림으로 표현한 것이다. 비유적으로 본다면 그림과 같이 파란색 상자들이 밀집하여 큰 공간을 이루고 있으며 이 큰 공간을 메모리라고 한다면 상자 하나씩은 1Byte의 정보를 담을 수 있는 크기이..
-
C언어를 위한 컴퓨터 구조C언어 2020. 2. 5. 21:25
컴퓨터 구조 C언어가 OS를 만들기 위해 탄생한 언어인 만큼 OS가 하는 일인 컴퓨터 자원 관리를 이해하기 위해서는 컴퓨터의 구조를 어느 정도 이해하고 학습을 해야 할 필요가 있다. 따라서 이번 포스트에서는 C언어를 학습하기 전 필요한 기초적인 컴퓨터의 구조에 대해서 다룰 것이다. 컴퓨터를 구성하는 코어 장치는 CPU (연산 장치) + RAM (메모리)가 있다. 추가적으로 HDD or SSD라는 보조기억장치가 있으며 해당 기기들은 주변기기이다. C언어를 사용할 때 사용자가 직접 사용하는 것은 RAM을 많이 사용하게 된다. + 용어 virtual mochine = 머신은 cpu를 의미하며 보통 인텔의 '' cpu라고 하면 하드웨어인 cpu 그 자체를 의미하며 버추얼 머신이라는 것은 cpu처럼 머신 역할을 ..
-
비트 개념과 2진법C언어 2020. 2. 5. 19:38
Bit 란 ? 전기 스위치 한개라고 생각하면 된다. 스위치 1개 == 1 Bit 와 같으며 전기 스위치가 on, off 두가지 경우의 수 ( 상태 ) 가 있는 것과 마찬가지로 1Bit에도 0(off) 과 1(on) 로 구분 할 수 있다. 보통 오늘 날의 사용자들은 32 bit or 64 bit 시스템을 사용할 것 이다. 여기서 설명하는 시스템은 os, 플랫폼 등의 용어로 표현 됨 여기서 말하는 bit의 개념은 위에서 설명한 전기 스위치와 같다고 보았을 때 스위치가 32개 or 64개가 있는 것 과 같다. 32 bit 기준 32 bit 시스템이라고 하면 해당 디바이스는 32개에 해당하는 스위치를 동시에 조합시켜 작동 시킨다는 의미이다. 따라서 32 bit 운영체제가 다룰 수 있는 수의 크기는 2의 32제곱..
-
C언어 프로그래밍을 이루는 세 가지 요소C언어 2020. 2. 5. 15:47
C언어 == 영어 둘다 같은 언어라는 개념을 가지고 있다. 영어의 목적은 무엇인가 ? 바로 소통에 목적이 있다. 즉 사람과 사람이 서로의 의견을 주고 받으면서 소통하기 위한 도구의 역할이다. 문법 같은 요소가 중요하긴 하지만 결국 언어라는 것은 소통하기 위한 도구임으로 소통 그자체에 의미를 둔다. 그렇다면 C언어라는 것의 목적은 무엇인가? 바로 프로그래밍에 있다. 즉 C언어라는 하나의 도구를 사용하여 프로그램을 작성하여 작성한 프로그램으로 컴퓨터를 원하는 방향으로 움직이게 만들기 위함이다. 최종적으로는 C언어 문법을 통해 프로그램을 작성하는 것이 C언어를 사용하는 목표라고 말 할 수 있다. 하지만 문법도 중요하지만 결국 프로그래밍을 만드는 만큼 어떻게 프로그램을 작성할지에 대한 부분이 더욱 중요하다고 볼..