-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
钟楚君
authored and
钟楚君
committed
Jul 27, 2020
1 parent
55e6109
commit e16866f
Showing
4 changed files
with
59 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#include <stdio.h> | ||
|
||
// 重定义数据类型 | ||
typedef unsigned char UINT8; | ||
typedef signed int INT32; | ||
|
||
// 函数声明 | ||
void FindStackDirection(void); | ||
|
||
INT32 main() | ||
{ | ||
FindStackDirection(); | ||
|
||
return 0; | ||
} | ||
|
||
void FindStackDirection(void) | ||
{ | ||
UINT8 iStackAddr = 0; // 用于获取栈地址 | ||
static UINT8 *pStackAddr = NULL; // 用于存放第一个iStackAddr的地址 | ||
|
||
if (pStackAddr == NULL) // 第一次进入 | ||
{ | ||
pStackAddr = &iStackAddr; // 保存iStackAddr的地址 | ||
FindStackDirection(); // 递归 | ||
} | ||
else // 第二次进入 | ||
{ | ||
if (&iStackAddr > pStackAddr) // 第二次iStackDirection的地址大于第一次iStackDirection, 那么说明栈增长方向是向上的 | ||
{ | ||
printf("Stack grows up!\n"); | ||
} | ||
else if (&iStackAddr < pStackAddr) // 第二次iStackDirection的地址小于第一次iStackDirection, 那么说明栈增长方向是向下的 | ||
{ | ||
printf("Stack grows down!\n"); | ||
} | ||
else | ||
{ | ||
printf("Bad stack!\n"); | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,5 @@ build-and-test: | |
|
||
xbuild src/Qiniu.sln | ||
|
||
nunit-console bin/QiniuTests.dll | ||
nunit-console bin/QiniuTests.dll | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters