Redian新闻
>
question about structure initializationa and reference
avatar
question about structure initializationa and reference# Programming - 葵花宝典
i*d
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
avatar
t*t
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).
avatar
i*d
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).

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。