일단은 이렇게 하면 static은 프로그램 끝날때까지 공간을 차지하고 변경도 안되고...
인자로 받아서 뭔가 static으로 만들어서 쓸만한 결과가 나오면 좋긴 하겠다만
#include <stdio.h>
char* func1()
{
static char* temp = "hello world";
return temp;
}
int* func2()
{
static int num = 10;
return #
}
int* func3(int* num)
{
static int* p = num;
return p;
}
int main(void)
{
int num = 100;
printf("%s\n",func1());
printf("%d\n",*func2());
printf("%d\n",*func3(&num));
return 0;
}
결과
hello world
10
100
'컴퓨터 과학 & 영상처리 관련 > C / C++' 카테고리의 다른 글
int와 float의 연산(정수와 소수) (0) | 2012.09.04 |
---|---|
devcpp getchar();getchar(); 대신 system("pause"); 가능 (0) | 2012.09.03 |
배열 포인터를 이용한 2차원 배열을 함수 인자로 주기.. (0) | 2012.09.03 |
2차원 배열을 1차원 포인터로 접근하여 출력하는 함수 (0) | 2012.08.27 |
sprintf 예제 (0) | 2012.08.21 |