如何在main.c中调用包含结构数组的函数? [英] How to call the function including arrays of structure in main.c?

查看:80
本文介绍了如何在main.c中调用包含结构数组的函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,谢谢!


我对C中的结构数组有疑问,以下是我的代码:


#include" system.h"

typedef struct

{int x,int y,int z;

short *速度;

浮动*波浪;

} Modeldim;


void myfunction(Modeldim * submodel);


int main(int argc,char * argv [])

{

int X = Y = Z = 1000;

int i,j,k;

int NUM = 10;


myfunction(Modeldim * submodel);


for(i = 0; i< NUM; i ++)

{

/ *这里是问题:

" myfunction()"可以将3D模型[X,Y,Z]拆分为10个子模型,然后设置每个子模型都有自己的变量,例如:

submodel [0] .x,submodel [0] .y ,submodel [0] .velocity,...

submodel [1] .x,submodel [1] .y,submodel [1] .velocity,...

submodel [2] .x,submodel [2] .y,submodel [2] .velocity,...

等等。

怎么打电话或者使用subdomain [i]在main.c?

* /

creat_model(subdomain [i] .x,subdomain [i] .y,subdomain [i] .velocity); /*这样对吗?我可以这样做吗?* /

}


};



如果没有,怎么样我可以在main.c中调用submodel [i]的参数吗?如果有人能回答,我非常感激。

First of all, thanks!

I have a problem about the arrays of structure in C, the following is my codes:

#include "system.h"

typedef struct
{ int x, int y, int z;
short *velocity ;
float *wave ;
} Modeldim ;

void myfunction(Modeldim *submodel) ;

int main(int argc, char *argv[])
{
int X=Y=Z=1000;
int i,j,k;
int NUM=10 ;

myfunction(Modeldim *submodel);

for (i=0; i< NUM; i++)
{
/* here is the question:
"myfunction()" can split 3D model [X,Y,Z] to 10 submodels, after that, and set every submodel has its own variables, eg:
submodel[0].x, submodel[0].y, submodel[0].velocity, ...
submodel[1].x, submodel[1].y, submodel[1].velocity, ...
submodel[2].x, submodel[2].y, submodel[2].velocity, ...
and so on.
how can I call or use "subdomain[i]" in main.c?
*/
creat_model(subdomain[i].x, subdomain[i].y, subdomain[i].velocity); /*Is it right? could I do that?*/
}

};


If not, how can I call the parameters of submodel[i] in main.c? If anyone can answr it, I am HIGHLY appreciated.

推荐答案

我最不理解你的问题。


你定义了:

I don''t understand most your question.

You defined:

展开 | 选择 | Wrap | 行号


谢谢。我仍然对结构感到困惑。

Thank you. I am still confused about the struct.

展开 | 选择 | Wrap | 行号


编译器说什么?


PS使用代码标签。
What does the compiler say?

P.S Use code tags.


这篇关于如何在main.c中调用包含结构数组的函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆