69,370
社区成员
发帖
与我相关
我的任务
分享
#include<stdio.h>
static int stack_dir = 0 ;
static void find_stack_dir()
{
static unsigned int* addr = NULL;
char dummy ;
char dummy1;
if(NULL == addr)
{
addr = &dummy;
printf("dummy's address:%x\n",&dummy);
printf("dummy1's address:%x\n",&dummy1);
find_stack_dir();
}
else
{
if(&dummy > addr)
stack_dir = 1;
else
stack_dir = -1;
return ;
}
}
int main()
{
find_stack_dir();
if(stack_dir == 1)
{
puts("stack grow upward\n");
}
else if(stack_dir == -1)
{
puts("stack grwp downward\n");
}
return 0;
}