由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - question about structure initializationa and reference
相关主题
C++一个string的小问题请问一个关于 cost of pointer的问题
关于C/C++里的Static variable的memory allocation/initializaWhat're the three types of memory allocated for C++ variables?
C++ Interview Question一个 default constructor 的问题
Is the order of initialization a, b, c or c, b, a?问个超简单的C问题
请教boost::any compile错误。问一个C++ set和unordered_set iterator的问题
static variable存在heap还是stack?effective C++里的memory pool 一问:
几个问题why do we still use dynamic allocation?
stack/heap corruptiona string define question (c++)
相关话题的讨论汇总
话题: structure话题: question话题: mygem话题: function
进入Programming版参与讨论
1 (共1页)
i****d
发帖数: 255
1
I have been using Fortran for many years but have to switch to C for the
current project. Get a question about structure initialization and would
appreciate any help!
I define a structure contatining a number of integers, reals, chars, and
arrays to be allocated. A point to such a structure is declared in the
main function, and I want to use a function to initialize this structure.
I know there must something wrong with my initialization function, but I
am unable to locate it. Many tutorials and
t****t
发帖数: 6806
2
1. you have to allocate memory for mygem, and have to do it in main (
otherwise the allocated address can't be passed back per your function
signature)
2. you don't have to allocate memory for array (mygem->quad). you do have to
allocate memory for pointer (mygem->vertex).
i****d
发帖数: 255
3
Thank you for the answer!
This is interesting. So I only can allocate memory for mygem in main!
Is there any other mean to do this sort of dynamical allocation?

to

【在 t****t 的大作中提到】
: 1. you have to allocate memory for mygem, and have to do it in main (
: otherwise the allocated address can't be passed back per your function
: signature)
: 2. you don't have to allocate memory for array (mygem->quad). you do have to
: allocate memory for pointer (mygem->vertex).

1 (共1页)
进入Programming版参与讨论
相关主题
a string define question (c++)请教boost::any compile错误。
c++环境入门问题static variable存在heap还是stack?
奇怪的问题:关于一个简单的malloc()小程序 (转载)几个问题
a=(char **)malloc(12*sizeof(char *)) 是什么意思?stack/heap corruption
C++一个string的小问题请问一个关于 cost of pointer的问题
关于C/C++里的Static variable的memory allocation/initializaWhat're the three types of memory allocated for C++ variables?
C++ Interview Question一个 default constructor 的问题
Is the order of initialization a, b, c or c, b, a?问个超简单的C问题
相关话题的讨论汇总
话题: structure话题: question话题: mygem话题: function