如何创建在C堆栈上的结构? [英] How to create a struct on the stack in C?
本文介绍了如何创建在C堆栈上的结构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道如何使用的malloc
堆上创建一个结构
。一直在寻找有关堆栈,而且所有文档上用C创建一个结构
一些文档。似乎谈论只堆结构创造。
I understand how to create a struct
on the heap using malloc
. Was looking for some documentation regarding creating a struct
in C on the stack but all docs. seem to talk about struct creation on heap only.
推荐答案
在声明堆栈上的任何变量相同的方式:
The same way you declare any variable on the stack:
struct my_struct {...};
int main(int argc, char **argv)
{
struct my_struct my_variable; // Declare struct on stack
.
.
.
}
这篇关于如何创建在C堆栈上的结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文