C 访问函数中的结构元素

C 访问函数中的结构元素,c,struct,compiler-errors,C,Struct,Compiler Errors,当我编译下面的代码时,会出现错误 snippet.c:24:24: error: request for member ‘px’ in something not a structure or union snippet.c:25:24: error: request for member ‘py’ in something not a structure or union snippet.c:27:22: error: request for member ‘x’ in something n

当我编译下面的代码时,会出现错误

snippet.c:24:24: error: request for member ‘px’ in something not a structure or union
snippet.c:25:24: error: request for member ‘py’ in something not a structure or union
snippet.c:27:22: error: request for member ‘x’ in something not a structure or union
snippet.c:27:45: error: request for member ‘y’ in something not a structure or union
snippet.c:31:14: error: request for member ‘x’ in something not a structure or union
snippet.c:35:16: error: request for member ‘y’ in something not a structure or union
snippet.c:39:25: error: request for member ‘px’ in something not a structure or union
snippet.c:40:25: error: request for member ‘py’ in something not a structure or union
对于下面的代码

struct list{
    int x;
int y;
int f;
int g;
int h;
int px;
int py;
};

void history(int j, struct list *path[], struct list *closelist[], struct list *start, int *fxele);
void history(int j, struct list *path[], struct list *closelist[], struct list *start, int *fxele){

int i, p;

path[0] = closelist[j];
p = 1;

struct list tempsq;

tempsq.x = (*closelist).px[j];
tempsq.y = (*closelist).py[j];

while(tempsq.x=!start.x && tempsq.y =! start.y){

for(i = 0; i <= *fxele; i++){

if(closelist.x[i] = tempsq.x){

    for(j = 0; j <= *fxele; j++){

        if(closelist.y[j] = tempsq.y){

            path[p] = closelist[j];
            p = p+1;
            tempsq.x = closelist.px[j];
            tempsq.y = closelist.py[j];

            }
        }   
    }
}
}

return;
}
struct列表{
int x;
int-y;
int f;
int g;
int-h;
int-px;
int-py;
};
无效历史记录(int j,结构列表*路径[],结构列表*关闭列表[],结构列表*开始,int*fxele);
无效历史记录(int j,结构列表*路径[],结构列表*关闭列表[],结构列表*开始,int*fxele){
int i,p;
路径[0]=关闭列表[j];
p=1;
结构列表tempsq;
tempsq.x=(*关闭列表).px[j];
tempsq.y=(*关闭列表).py[j];
while(tempsq.x=!start.x&&tempsq.y=!start.y){
对于(i=0;i这些陈述

tempsq.x = (*closelist).px[j];
tempsq.y = (*closelist).py[j];  
你错了。
px
py
不是您的结构中的数组。请尝试此操作

tempsq.x = closelist[j].px;
tempsq.y = closelist[j].py;
假设“l”是某种结构类型“list”的数组,“b”是该结构中某个字段的名称:

struct list {
    int b;
};

struct list l[10];
如果键入:

l.b[0];
这是不正确的。要从数组中的第一个“list”结构中获取“b”,应键入:

l[0].b;
因为函数“history”的一个参数是:

这意味着您要传递一个指向列表结构数组的指针,因此,如果您想要第j个结构中的px和py数据成员,则必须键入:

(*closelist)[j].px;
(*closelist)[j].py;
(*closelist)[j].px;
(*closelist)[j].py;