tstack.htm

来自「Thinking in C 电子书的源代码」· HTM 代码 · 共 26 行

HTM
26
字号
<html><font size="+1"><pre>
/* tstack.c: Tests the stack of ints */
#include "stack.h"
#include &lt;stdio.h&gt;

int main() {
    int i;
    
    /* Populate stack */
    for (i = 0; i &lt; 11; ++i)
        stk_push(i);
    if (stk_error())
        puts("stack error");
    printf("The last element pushed was %d\n",
           stk_top());
    
    /* Pop/print stack */
    while (stk_size() &gt; 0)
        printf("%d ", stk_pop());
    putchar('\n');
    if (!stk_error())
        puts("no stack error");
    return 0;
}

</pre></font></html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?