티스토리 뷰

Coding/C

static 및 extern // case03

빠리빵 2018. 5. 20. 12:21
staticFunc1.cpp
#include
#include

extern void func(void);

static int sqr(int a) {
	return a*a;
}

void main(void) {
	func();
	printf("%d\n", sqr(3));

	system("pause");
}

staticFunc2.cpp
#include 

static int sqr(int a) {
	return a * a * 2;

}

void func(void) {
	printf("%d\n", sqr(3));
}

함수에도 static이 적용된다. 출력은 18 9

각각의 파일에 static int sqr(int a) 함수가 있기 때문에 그 함수을 실행한다


'Coding > C' 카테고리의 다른 글

little endian과 big endian  (0) 2018.05.22
포인터의 연산  (0) 2018.05.22
pointer 와 선치, 후치 연산자  (0) 2018.05.20
static 및 extern // case02  (0) 2018.05.20
static 및 extern // case01  (0) 2018.05.20
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함