推送和弹出堆栈? [英] Pushes and Pops to/from stack?
问题描述
在Ansi-C C99或标准C或GCC中......
有没有办法将值推入堆栈然后再检索它
在同一个函数中?
void foo(void){
In Ansi-C C99 or Standard C or in GCC...
Is there a way to push a value onto the stack and then later retrieve it
within the same function?
void foo(void) {
推荐答案
Kenneth Lantrip写道在30/07/04:
Kenneth Lantrip wrote on 30/07/04 :
在Ansi-C C99或标准C或GCC中...
有没有办法将值推入堆栈然后以后在同一个函数中检索它
void foo(void){
。
。
在这里推动我的价值;
。
。
在这里弹出我的价值;
。
。
或者这只依赖于机器和/或编译器吗?
In Ansi-C C99 or Standard C or in GCC...
Is there a way to push a value onto the stack and then later retrieve it
within the same function?
void foo(void) {
.
.
push my value here;
.
.
pop my value here;
.
.
}
Or is this only machine dependant and/or compiler dependant?
在标准C中无法使用,因为
stabdard不需要机器堆栈,但您可以在标准中编写自己的堆栈系统C如果你对b $ b感兴趣,你需要一个索引,一个三个函数的数组,用于
例如:
typedef struct
{
size_t sp;
size_t size;
unsigned long * p;
}
stk_s;
int stk_init( stk_s * this,unsigned long * p,size_t size);
int stk_push(stk_s * this,unsigned long data);
int stk_pop(stk_s * this,unsigned long * p_data);
你也可以有一个完整的动态版本:
stk_s * stk_create(size_t size);
void此stk_delete(stk_s * this);
int stk_push(stk_s * this,unsigned long data);
int stk_pop(stk_s * this,unsigned long * p_data);
-
Emmanuel
C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
C是一个敏锐的工具
No way in standard C, because the machine stack is not required by the
stabdard, but you can write your own stack system in standard C if you
are interested in. You need an index, an array an three functions, for
example:
typedef struct
{
size_t sp;
size_t size;
unsigned long *p;
}
stk_s;
int stk_init (stk_s *this, unsigned long *p, size_t size);
int stk_push (stk_s *this, unsigned long data);
int stk_pop (stk_s *this, unsigned long *p_data);
You also could have a full dynamic version:
stk_s *stk_create (size_t size);
void this stk_delete (stk_s *this);
int stk_push (stk_s *this, unsigned long data);
int stk_pop (stk_s *this, unsigned long *p_data);
--
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
"C is a sharp tool"
Kenneth Lantrip< nu *** @ bidny。 OK>写道:
Kenneth Lantrip <nu***@bidny.ok> wrote:
在Ansi-C C99或标准C或GCC中...
有没有办法将值推入堆栈然后在其中检索
功能相同?
void foo(无效){
。
。
在这里推动我的价值;
。
。
在这里突显我的价值;
。
。
}
或者这只依赖于机器和/或编译器依赖吗?
In Ansi-C C99 or Standard C or in GCC... Is there a way to push a value onto the stack and then later retrieve it
within the same function? void foo(void) {
.
.
push my value here;
.
.
pop my value here;
.
.
} Or is this only machine dependant and/or compiler dependant?
如果存在这样的事情然后它是编译器依赖的扩展,
C89和C99都没有表示单词stack。一点都不什么
你究竟需要它(除非你搞乱了嵌入在C代码中的
汇编程序代码 - 然后你可以做到这一点
无论如何从汇编程序推送和弹出)?
问候,Jens
-
\ Jens Thoms Toerring ___ Je***********@physik.fu-berlin.de
\ __________________________ http://www.toerring.de
(取代< mn *********************** @ YOURBRAnoos。 fr>)
Kenneth Lantrip在30/07/04写道:
(supersedes <mn***********************@YOURBRAnoos.fr>)
Kenneth Lantrip wrote on 30/07/04 :
在Ansi-C C99或标准C或GCC中......
有没有办法将值推入堆栈然后在同一函数中检索它?
void foo(void){
。
。
在这里推动我的价值;
。
。
弹出我的价值在这里;
。
。
}
或者这只是依赖于机器和/或编译器的吗?
In Ansi-C C99 or Standard C or in GCC...
Is there a way to push a value onto the stack and then later retrieve it
within the same function?
void foo(void) {
.
.
push my value here;
.
.
pop my value here;
.
.
}
Or is this only machine dependant and/or compiler dependant?
标准C中无法使用,因为
标准不需要机器堆栈,但是如果你是
,你可以在标准C中编写自己的堆栈系统你需要一个索引,一个三个函数的数组,对于
例如:
typedef struct
{
size_t sp;
size_t size;
unsigned long * p;
}
stk_s;
int stk_init(stk_s * this,unsigned long * p,size_t size);
int stk_push(stk_s * this,unsigned long data) ;
int stk_pop(stk_s * this,unsigned long * p_data);
您还可以拥有完整的动态版本:
>
stk_s * stk_create(size_t size);
void此stk_delete(stk_s * this);
int stk_push(stk_s * this,unsigned long data);
int stk_pop(stk_s * t他的,unsigned long * p_data);
-
Emmanuel
C-FAQ: http://www.eskimo.com/~scs/C-faq/faq。 HTML
C是一个尖锐的工具
No way in standard C, because the machine stack is not required by the
standard, but you can write your own stack system in standard C if you
are interested in. You need an index, an array an three functions, for
example:
typedef struct
{
size_t sp;
size_t size;
unsigned long *p;
}
stk_s;
int stk_init (stk_s *this, unsigned long *p, size_t size);
int stk_push (stk_s *this, unsigned long data);
int stk_pop (stk_s *this, unsigned long *p_data);
You also could have a full dynamic version:
stk_s *stk_create (size_t size);
void this stk_delete (stk_s *this);
int stk_push (stk_s *this, unsigned long data);
int stk_pop (stk_s *this, unsigned long *p_data);
--
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
"C is a sharp tool"
这篇关于推送和弹出堆栈?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!