250304 Hello, World! ์ถ๋ ฅ
๐ Today's Contents ๐
Visual Studio์์ C์ธ์ด๋ก Hello, World! ์ถ๋ ฅํ๊ธฐ
1. ์ค๋ ๋ฐฐ์ด ๊ฐ๋ฐ์ฉ์ด
a. #: ์ ์ฒ๋ฆฌ๊ธฐ (Pre-Processor)
b. #include
c. <>์ ์๋ฏธ : ๊ฒฝ๋ก
d. stdio: Standard Input/Output
e. .h(ํ์ฅ์) & .c(ํ์ฅ์)
f. ํจ์ (Function)
g. ์๋ฃํ (Data-Type)
h. int (Integer) : ์ ์
i. ()์ ์๋ฏธ : ๋งค๊ฐ๋ณ์ (Parameter)
j. {}์ ์๋ฏธ : ์ฝ๋๋ธ๋ก ์ ์
k. printf ( Print Format ) : ๋ฌธ์์ด ์ถ๋ ฅ
l. ๋ฌธ์ (Character) : ‘ ‘ (์์๋ฐ์ดํ)
m. ๋ฌธ์์ด (String) : “ “ (ํฐ๋ฐ์ดํ)
n. ์ธ์ (Arguments)
o. return : ํจ์์ข ๋ฃ, ๊ฒฐ๊ณผ๊ฐ์ ๋ฐํ
Visual Studio์์ C์ธ์ด๋ก Hello, World! ์ถ๋ ฅํ๊ธฐ
//์ฃผ์(comments)- ์ปดํ์ผํ ๋ ์ ๋ค์ด๊ฐ, ์ค ์์ ํฌํจ ์๋จ : ํ ์ค๋ก ์ฒ๋ฆฌํ๋ ์ฃผ์
/*
์ฌ๊ธฐ๋
์ ๋ถ
์ฃผ์์
๋๋ค. (์ฌ๋ฌ์ค ์ฃผ์)
*/
#include <stdio.h>
int main(void)
{
printf("Hello,World!\n");
return 0;
}
1. ์ค๋ ๋ฐฐ์ด ๊ฐ๋ฐ์ฉ์ด
#include <stdio.h>
a. #: ์ ์ฒ๋ฆฌ๊ธฐ (Pre-Processor)
์ ์ฒ๋ฆฌ๊ธฐ๋ C ํ๋ก๊ทธ๋จ์์ ์ปดํ์ผ ์ ์ ๋ฏธ๋ฆฌ ์ฒ๋ฆฌ๋๋ ๋ถ๋ถ.
์ฐ๋ฆฌ๊ฐ ์์ฑํ ์ฝ๋๊ฐ ์ปดํ์ผ๋ฌ์ ์ํด ๋ฒ์ญ๋๊ธฐ ์ ์ ์ ์ฒ๋ฆฌ๊ธฐ ์ง์๋ฌธ(Preprocessor Directive)์ด ๋จผ์ ์คํ๋จ.
b. #include
C ์ธ์ด์์ ํค๋ ํ์ผ์ ํฌํจํ๋ ์ ์ฒ๋ฆฌ ์ง์๋ฌธ.
ํ๋ก๊ทธ๋จ์ด ์คํ๋๊ธฐ ์ ์ ๋ฏธ๋ฆฌ ์์ฑ๋ ์ฝ๋(๋ผ์ด๋ธ๋ฌ๋ฆฌ)๋ฅผ ๋ถ๋ฌ์ค๋ ์ญํ ์ ํจ.
c. <>์ ์๋ฏธ : ๊ฒฝ๋ก
< >๋ฅผ ์ฌ์ฉํ๋ฉด ์ปดํ์ผ๋ฌ๊ฐ ์ค์ ๋ ์์คํ ๊ฒฝ๋ก(ํ์ค ๋ผ์ด๋ธ๋ฌ๋ฆฌ ๊ฒฝ๋ก)์์ ํค๋ ํ์ผ์ ๊ฒ์ํจ.
d. stdio: Standard Input/Output
stdio๋ Standard Input/Output(ํ์ค ์ ์ถ๋ ฅ)์ ์ค์๋ง๋ก, C ์ธ์ด์์ ์ ๋ ฅ๊ณผ ์ถ๋ ฅ์ ์ฒ๋ฆฌํ๋ ๊ธฐ๋ฅ์ ์ ๊ณตํ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ
e. .h(ํค๋ํ์ผ) & .c(์์คํ์ผ)
๐ ํค๋ ํ์ผ์ ํจ์์ ์ ์ธ๋ถ๋ฅผ ์ ์ฅํ๋ ํ์ผ์.
-> ํจ์์ ์ด๋ฆ๊ณผ ํ์๋ง ์ ๊ณ , ์ค์ ์คํ ๋ด์ฉ(๊ตฌํ๋ถ)๋ .c ํ์ผ์ ์์.
๐ก ํค๋ ํ์ผ์ ์ฌ๋ฌ .c ํ์ผ์์ ๊ณตํต์ผ๋ก ์ฌ์ฉ๋ ์ฝ๋๋ฅผ ๊ด๋ฆฌํ๊ธฐ ์ํด ์ฌ์ฉ๋จ.
int main(void)
{
printf("Hello,World!\n");
return 0;
}
h. int (Integer) : ์ ์
๐ int๋ C ์ธ์ด์์ ์ ์๋ฅผ ์ ์ฅํ๋ ์๋ฃํ(Data Type)์.
i. ()์ ์๋ฏธ : ๋งค๊ฐ๋ณ์ (Parameter)
๐ ๋งค๊ฐ๋ณ์๋ ํจ์์ ๊ฐ์ ์ ๋ฌํ๋ ์ญํ ์ ํจ.
j. {}์ ์๋ฏธ : ์ฝ๋๋ธ๋ก ์ ์
ํจ์(Function)๋ ์กฐ๊ฑด๋ฌธ, ๋ฐ๋ณต๋ฌธ ๋ฑ์์ ์คํํ ์ฝ๋์ ๋ฒ์๋ฅผ ์ง์ ํ๋ ๋ฐ ์ฌ์ฉ.
k. printf ( Print Format ) : ๋ฌธ์์ด ์ถ๋ ฅ
printf๋ C ์ธ์ด์์ ๋ฌธ์์ด์ ์ถ๋ ฅํ๋ ํจ์.
printf()๋ฅผ ์ฌ์ฉํ๋ฉด ํ
์คํธ, ์ซ์, ๋ณ์ ๊ฐ ๋ฑ์ ํ๋ฉด์ ์ถ๋ ฅํ ์ ์์.