SlideShare a Scribd company logo
1 of 8
Download to read offline
C !
http://blog.naver.com/ruvendix
함수의 개념
printf()처럼 어떤 작업을 반복적으로 처리하고 싶은데…
반복문으로는 해결이 안되고… 어떻게 하지…?
그래! 함수를 직접 만들자!
http://blog.naver.com/ruvendix
함수의 선언과 정의
함수를 먼저 호출해야 한다면? 선언부터 하자!
선언하기가 귀찮다! 그러면 정의부터 하자!
http://blog.naver.com/ruvendix
매개변수와 인자
int Add(int iNum1, int iNum2)
{
return (iNum 1 + iNum2);
}
Add(10, 20);
매개변수는 함수의 선언 또는 정의에 있다!
함수를 호출할 때 매개변수로 넘겨주는 것이 인자!
10과 20은 Add()의 인자
http://blog.naver.com/ruvendix
함수의 형식
int main(void)
{
return 0;
}
void main(void)
{
return;
}
void main(int A)
{
return;
}
int main(int A)
{
return A;
}
※
http://blog.naver.com/ruvendix
지역 변수와 전역 변수
int g_iNum;
int main(void)
{
int iNum;
return 0;
}
전역 변수란?
함수 밖에서도 사용 가능한 변수
지역 변수란?
함수 안에서만 사용 가능한 변수
http://blog.naver.com/ruvendix
static 예약어
static int g_iNum;
int main(void)
{
static int iNum;
return 0;
}
전역 변수에서 사용되면?
소스 파일 안에서만 사용 가능한 변수
지역 변수에서 사용되면?
함수를 빠져나가도 기존 값 유지
http://blog.naver.com/ruvendix

More Related Content

What's hot

[C++ Korea] Effective Modern C++ Study, Item 1 - 3
[C++ Korea] Effective Modern C++ Study, Item 1 - 3[C++ Korea] Effective Modern C++ Study, Item 1 - 3
[C++ Korea] Effective Modern C++ Study, Item 1 - 3Chris Ohk
 
[C++ Korea] Effective Modern C++ MVA item 8 Prefer nullptr to 0 and null +윤석준
[C++ Korea] Effective Modern C++ MVA item 8 Prefer nullptr to 0 and null +윤석준[C++ Korea] Effective Modern C++ MVA item 8 Prefer nullptr to 0 and null +윤석준
[C++ Korea] Effective Modern C++ MVA item 8 Prefer nullptr to 0 and null +윤석준Seok-joon Yun
 
C++ 타입 추론
C++ 타입 추론C++ 타입 추론
C++ 타입 추론Huey Park
 
[C++ Korea] Effective Modern C++ Study item14 16 +신촌
[C++ Korea] Effective Modern C++ Study item14 16 +신촌[C++ Korea] Effective Modern C++ Study item14 16 +신촌
[C++ Korea] Effective Modern C++ Study item14 16 +신촌Seok-joon Yun
 
[C++ korea] effective modern c++ study item 14 declare functions noexcept if ...
[C++ korea] effective modern c++ study item 14 declare functions noexcept if ...[C++ korea] effective modern c++ study item 14 declare functions noexcept if ...
[C++ korea] effective modern c++ study item 14 declare functions noexcept if ...Seok-joon Yun
 
[C++ Korea] Effective Modern C++ mva item 7 distinguish between and {} when c...
[C++ Korea] Effective Modern C++ mva item 7 distinguish between and {} when c...[C++ Korea] Effective Modern C++ mva item 7 distinguish between and {} when c...
[C++ Korea] Effective Modern C++ mva item 7 distinguish between and {} when c...Seok-joon Yun
 
코딩인카페 C&JAVA 기초과정 C프로그래밍(2)
코딩인카페 C&JAVA 기초과정 C프로그래밍(2)코딩인카페 C&JAVA 기초과정 C프로그래밍(2)
코딩인카페 C&JAVA 기초과정 C프로그래밍(2)유익아카데미
 
2. c언어의 기본
2. c언어의 기본2. c언어의 기본
2. c언어의 기본SeonMan Kim
 
2 1. variables & data types
2 1. variables & data types2 1. variables & data types
2 1. variables & data types웅식 전
 
[C++ korea] Effective Modern C++ study item 19 use shared ptr for shared owne...
[C++ korea] Effective Modern C++ study item 19 use shared ptr for shared owne...[C++ korea] Effective Modern C++ study item 19 use shared ptr for shared owne...
[C++ korea] Effective Modern C++ study item 19 use shared ptr for shared owne...Seok-joon Yun
 
C++17 Key Features Summary - Ver 2
C++17 Key Features Summary - Ver 2C++17 Key Features Summary - Ver 2
C++17 Key Features Summary - Ver 2Chris Ohk
 
Hello c++ world
Hello c++ worldHello c++ world
Hello c++ world. Ruvendix
 
코딩인카페 C&JAVA 기초과정 C프로그래밍(3)
코딩인카페 C&JAVA 기초과정 C프로그래밍(3)코딩인카페 C&JAVA 기초과정 C프로그래밍(3)
코딩인카페 C&JAVA 기초과정 C프로그래밍(3)유익아카데미
 
C++20 Key Features Summary
C++20 Key Features SummaryC++20 Key Features Summary
C++20 Key Features SummaryChris Ohk
 
(학생용)+프로그래밍+및+실습 Chap4 3
(학생용)+프로그래밍+및+실습 Chap4 3(학생용)+프로그래밍+및+실습 Chap4 3
(학생용)+프로그래밍+및+실습 Chap4 3guestc0587d1
 
코딩인카페 C&JAVA 기초과정 C프로그래밍(1)
코딩인카페 C&JAVA 기초과정 C프로그래밍(1)코딩인카페 C&JAVA 기초과정 C프로그래밍(1)
코딩인카페 C&JAVA 기초과정 C프로그래밍(1)유익아카데미
 
Hoons 닷넷 정기세미나
Hoons 닷넷 정기세미나Hoons 닷넷 정기세미나
Hoons 닷넷 정기세미나병걸 윤
 
[C++ Korea 2nd Seminar] C++17 Key Features Summary
[C++ Korea 2nd Seminar] C++17 Key Features Summary[C++ Korea 2nd Seminar] C++17 Key Features Summary
[C++ Korea 2nd Seminar] C++17 Key Features SummaryChris Ohk
 
[C++ Korea] Effective Modern C++ Study item 24-26
[C++ Korea] Effective Modern C++ Study item 24-26[C++ Korea] Effective Modern C++ Study item 24-26
[C++ Korea] Effective Modern C++ Study item 24-26Seok-joon Yun
 

What's hot (20)

[C++ Korea] Effective Modern C++ Study, Item 1 - 3
[C++ Korea] Effective Modern C++ Study, Item 1 - 3[C++ Korea] Effective Modern C++ Study, Item 1 - 3
[C++ Korea] Effective Modern C++ Study, Item 1 - 3
 
C++11
C++11C++11
C++11
 
[C++ Korea] Effective Modern C++ MVA item 8 Prefer nullptr to 0 and null +윤석준
[C++ Korea] Effective Modern C++ MVA item 8 Prefer nullptr to 0 and null +윤석준[C++ Korea] Effective Modern C++ MVA item 8 Prefer nullptr to 0 and null +윤석준
[C++ Korea] Effective Modern C++ MVA item 8 Prefer nullptr to 0 and null +윤석준
 
C++ 타입 추론
C++ 타입 추론C++ 타입 추론
C++ 타입 추론
 
[C++ Korea] Effective Modern C++ Study item14 16 +신촌
[C++ Korea] Effective Modern C++ Study item14 16 +신촌[C++ Korea] Effective Modern C++ Study item14 16 +신촌
[C++ Korea] Effective Modern C++ Study item14 16 +신촌
 
[C++ korea] effective modern c++ study item 14 declare functions noexcept if ...
[C++ korea] effective modern c++ study item 14 declare functions noexcept if ...[C++ korea] effective modern c++ study item 14 declare functions noexcept if ...
[C++ korea] effective modern c++ study item 14 declare functions noexcept if ...
 
[C++ Korea] Effective Modern C++ mva item 7 distinguish between and {} when c...
[C++ Korea] Effective Modern C++ mva item 7 distinguish between and {} when c...[C++ Korea] Effective Modern C++ mva item 7 distinguish between and {} when c...
[C++ Korea] Effective Modern C++ mva item 7 distinguish between and {} when c...
 
코딩인카페 C&JAVA 기초과정 C프로그래밍(2)
코딩인카페 C&JAVA 기초과정 C프로그래밍(2)코딩인카페 C&JAVA 기초과정 C프로그래밍(2)
코딩인카페 C&JAVA 기초과정 C프로그래밍(2)
 
2. c언어의 기본
2. c언어의 기본2. c언어의 기본
2. c언어의 기본
 
2 1. variables & data types
2 1. variables & data types2 1. variables & data types
2 1. variables & data types
 
[C++ korea] Effective Modern C++ study item 19 use shared ptr for shared owne...
[C++ korea] Effective Modern C++ study item 19 use shared ptr for shared owne...[C++ korea] Effective Modern C++ study item 19 use shared ptr for shared owne...
[C++ korea] Effective Modern C++ study item 19 use shared ptr for shared owne...
 
C++17 Key Features Summary - Ver 2
C++17 Key Features Summary - Ver 2C++17 Key Features Summary - Ver 2
C++17 Key Features Summary - Ver 2
 
Hello c++ world
Hello c++ worldHello c++ world
Hello c++ world
 
코딩인카페 C&JAVA 기초과정 C프로그래밍(3)
코딩인카페 C&JAVA 기초과정 C프로그래밍(3)코딩인카페 C&JAVA 기초과정 C프로그래밍(3)
코딩인카페 C&JAVA 기초과정 C프로그래밍(3)
 
C++20 Key Features Summary
C++20 Key Features SummaryC++20 Key Features Summary
C++20 Key Features Summary
 
(학생용)+프로그래밍+및+실습 Chap4 3
(학생용)+프로그래밍+및+실습 Chap4 3(학생용)+프로그래밍+및+실습 Chap4 3
(학생용)+프로그래밍+및+실습 Chap4 3
 
코딩인카페 C&JAVA 기초과정 C프로그래밍(1)
코딩인카페 C&JAVA 기초과정 C프로그래밍(1)코딩인카페 C&JAVA 기초과정 C프로그래밍(1)
코딩인카페 C&JAVA 기초과정 C프로그래밍(1)
 
Hoons 닷넷 정기세미나
Hoons 닷넷 정기세미나Hoons 닷넷 정기세미나
Hoons 닷넷 정기세미나
 
[C++ Korea 2nd Seminar] C++17 Key Features Summary
[C++ Korea 2nd Seminar] C++17 Key Features Summary[C++ Korea 2nd Seminar] C++17 Key Features Summary
[C++ Korea 2nd Seminar] C++17 Key Features Summary
 
[C++ Korea] Effective Modern C++ Study item 24-26
[C++ Korea] Effective Modern C++ Study item 24-26[C++ Korea] Effective Modern C++ Study item 24-26
[C++ Korea] Effective Modern C++ Study item 24-26
 

Viewers also liked

Viewers also liked (20)

반복문과 선택문
반복문과 선택문반복문과 선택문
반복문과 선택문
 
표준 입출력
표준 입출력표준 입출력
표준 입출력
 
배열
배열배열
배열
 
연산자
연산자연산자
연산자
 
Hareka presentation
Hareka presentationHareka presentation
Hareka presentation
 
2 клас урок 3 сучасні комп'ютери
2 клас урок 3 сучасні комп'ютери2 клас урок 3 сучасні комп'ютери
2 клас урок 3 сучасні комп'ютери
 
자료형과 값
자료형과 값자료형과 값
자료형과 값
 
Capincho cuento con ilustraciones individual
Capincho cuento con ilustraciones individualCapincho cuento con ilustraciones individual
Capincho cuento con ilustraciones individual
 
Battling Google PageSpeed Insights
Battling Google PageSpeed InsightsBattling Google PageSpeed Insights
Battling Google PageSpeed Insights
 
Conversacion
ConversacionConversacion
Conversacion
 
구조체
구조체구조체
구조체
 
포인터
포인터포인터
포인터
 
presentation on blind pepole
presentation on blind pepolepresentation on blind pepole
presentation on blind pepole
 
関西NIPS+読み会発表スライド
関西NIPS+読み会発表スライド関西NIPS+読み会発表スライド
関西NIPS+読み会発表スライド
 
Divya bhaskar vs guj. (1) (1)
Divya bhaskar vs guj. (1) (1)Divya bhaskar vs guj. (1) (1)
Divya bhaskar vs guj. (1) (1)
 
2 клас урок 4 з чого складається комп’ютер
2 клас урок 4  з чого складається комп’ютер 2 клас урок 4  з чого складається комп’ютер
2 клас урок 4 з чого складається комп’ютер
 
Hello world
Hello worldHello world
Hello world
 
전처리기
전처리기전처리기
전처리기
 
Diseño de areas verdes
Diseño de areas verdesDiseño de areas verdes
Diseño de areas verdes
 
동적할당
동적할당동적할당
동적할당
 

Similar to 함수

More effective c++ chapter1 2_dcshin
More effective c++ chapter1 2_dcshinMore effective c++ chapter1 2_dcshin
More effective c++ chapter1 2_dcshinDong Chan Shin
 
Function & Closure about Swift
Function & Closure about Swift Function & Closure about Swift
Function & Closure about Swift KimDaeho
 
[Swift] Functions
[Swift] Functions[Swift] Functions
[Swift] FunctionsBill Kim
 
연산자 오버로딩
연산자 오버로딩연산자 오버로딩
연산자 오버로딩. Ruvendix
 
Kgc2006 Template Metaprogramming을 이용한 LuaTinker 구현
Kgc2006 Template Metaprogramming을 이용한 LuaTinker 구현Kgc2006 Template Metaprogramming을 이용한 LuaTinker 구현
Kgc2006 Template Metaprogramming을 이용한 LuaTinker 구현Sang Goo Kwon
 
Pure Function and Honest Design
Pure Function and Honest DesignPure Function and Honest Design
Pure Function and Honest DesignHyungho Ko
 
About Visual C++ 10
About  Visual C++ 10About  Visual C++ 10
About Visual C++ 10흥배 최
 
Effective c++(chapter 5,6)
Effective c++(chapter 5,6)Effective c++(chapter 5,6)
Effective c++(chapter 5,6)문익 장
 
포인터의기초 (2) - 포인터 사용하기1
포인터의기초 (2) - 포인터 사용하기1포인터의기초 (2) - 포인터 사용하기1
포인터의기초 (2) - 포인터 사용하기1Hoyoung Jung
 

Similar to 함수 (11)

More effective c++ chapter1 2_dcshin
More effective c++ chapter1 2_dcshinMore effective c++ chapter1 2_dcshin
More effective c++ chapter1 2_dcshin
 
Changes in c++0x
Changes in c++0xChanges in c++0x
Changes in c++0x
 
Function & Closure about Swift
Function & Closure about Swift Function & Closure about Swift
Function & Closure about Swift
 
6 swift 고급함수
6 swift 고급함수6 swift 고급함수
6 swift 고급함수
 
[Swift] Functions
[Swift] Functions[Swift] Functions
[Swift] Functions
 
연산자 오버로딩
연산자 오버로딩연산자 오버로딩
연산자 오버로딩
 
Kgc2006 Template Metaprogramming을 이용한 LuaTinker 구현
Kgc2006 Template Metaprogramming을 이용한 LuaTinker 구현Kgc2006 Template Metaprogramming을 이용한 LuaTinker 구현
Kgc2006 Template Metaprogramming을 이용한 LuaTinker 구현
 
Pure Function and Honest Design
Pure Function and Honest DesignPure Function and Honest Design
Pure Function and Honest Design
 
About Visual C++ 10
About  Visual C++ 10About  Visual C++ 10
About Visual C++ 10
 
Effective c++(chapter 5,6)
Effective c++(chapter 5,6)Effective c++(chapter 5,6)
Effective c++(chapter 5,6)
 
포인터의기초 (2) - 포인터 사용하기1
포인터의기초 (2) - 포인터 사용하기1포인터의기초 (2) - 포인터 사용하기1
포인터의기초 (2) - 포인터 사용하기1
 

More from . Ruvendix

Google coding guide
Google coding guideGoogle coding guide
Google coding guide. Ruvendix
 
상속과 다형성
상속과 다형성상속과 다형성
상속과 다형성. Ruvendix
 
클래스의 추가 지식
클래스의 추가 지식클래스의 추가 지식
클래스의 추가 지식. Ruvendix
 
여러 생성자
여러 생성자여러 생성자
여러 생성자. Ruvendix
 
클래스의 기초 지식
클래스의 기초 지식클래스의 기초 지식
클래스의 기초 지식. Ruvendix
 

More from . Ruvendix (8)

Google coding guide
Google coding guideGoogle coding guide
Google coding guide
 
형식 선정
형식 선정형식 선정
형식 선정
 
예외 처리
예외 처리예외 처리
예외 처리
 
템플릿
템플릿템플릿
템플릿
 
상속과 다형성
상속과 다형성상속과 다형성
상속과 다형성
 
클래스의 추가 지식
클래스의 추가 지식클래스의 추가 지식
클래스의 추가 지식
 
여러 생성자
여러 생성자여러 생성자
여러 생성자
 
클래스의 기초 지식
클래스의 기초 지식클래스의 기초 지식
클래스의 기초 지식
 

함수