【发布时间】:2020-05-22 14:47:36
【问题描述】:
我正在尝试传递如图所示的点数组结构,如何正确取消引用地址以更改地址指向的值。
// header file "header.h"
typedef struct {
double x;
double y;
} Pointbase;
typedef Pointbase *XYpt;
typedef struct {
XYpt xy[1];
} ChartPointsbase;
typedef ChartPointsbase **PointArray;
#include "header.h"
...
void npCluster(double drop, XYpt *newpt, PointArray outpts)
{
double xx[2]={-15, 100};
int i;
outpts = (PointArray)malloc(sizeof(PointArray) * 2);
for (i=0;i<2; i++)
{
(*(*outpts)->xy[i])->x=xx[i];
(*(*outpts)->xy[i])->y=drop;
}
}
编译器喜欢以下行但不计算
(*outpts)->xy[i]->y=drop;
任何建议将不胜感激。
【问题讨论】:
-
我忘了补充,我想用这个函数来操作各种点数组来绘制图表。点数组的典型大小为 3000 个双点。
-
您有一个包含一个指针的数组:
XYpt xy[1];从 0 到 2 的索引将无效:->xy[i][并且:请删除愚蠢的 typedef。他们只是令人困惑]
标签: pointers data-structures dereference