stack 은 보통 아래로쌓이고 heap은 위로쌓이잖아요?
근데 심심해서 코드를 작성해서 둘이 만나게하려했는데 실제로 만나진 않네요?
힙과 스택사이에도 공간이 있나요?
코드는
#include
#include
void rec(int depth)
{
int stack[1000];
printf(depth : %d\n", depth);
printf("stack : %p ", stack); //스택 할당주소
int*ptr = (int*)malloc(sizeof(int)*1000);
printf("heap : %p\n, ptr); //힙 할당주소
rec(++depth);
}
int main()
{
int depth = 0;
rec(depth);
}
찾아보니 스택에 제한이 있다고해서 제한을 풀어줬는데도 튕길때 마지막 값이 같진 않네요