【发布时间】:2021-06-02 10:37:17
【问题描述】:
我正在尝试使用 Struct 节点和链表进行分配。这是我遇到无法解决的错误的一小部分代码。请帮助提前谢谢。
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
struct term{
char term[200];
double value;
};
void main(){
struct term **terms = (struct term *)malloc(sizeof(struct term));
// Using **terms is mandatory for the project
*terms[0]->term = "abc";
*terms[0]->value = 1; //This is line 15
//I am unable to fix the error in line 15 at "*terms".
//The error message states "Struct term **terms: Operend of '*' must be a pointer"
//The goal is to create nodes that can be accessed using *terms[i] with a for loop of index i
}
【问题讨论】:
-
"terms" 是一个 **,您将取消对它的引用 3 次:一次使用 *,一次使用 [],一次使用 ->。您的意思可能是“terms[0]->term”。
-
我们通常会快速回复,但我们不会按照您的日程安排工作,因此我们通常不会接受快速回复的请求。
-
非常感谢!它解决了问题