嗨,我或多或少是 c 的新手,在学习如何使用结构和 union 时,我收到了这个错误:“';' 标记之前的预期表达式”我一直在寻找错误很长一段时间,但我找不到它。我所要求的只是在以下代码中需要的地方进行更正。
我在 mac os x 上使用 Gnu C 编译器
#include <stdio.h>;
#include <stdlib.h>;
struct lista;
struct elemento;
union member{
int i;
struct lista * n;};
struct elemento{
union member * v;
struct elemento * n;};
struct lista{
int len;
struct elemento * n;};
void append(struct lista* a , union member * e);
int main(void){
return 0;}
void append(struct lista * a , union member * e){
struct elemento ** j= ((*a).n)*; /* error here */
int c;
for(c=0;c<(*a).len;c++){
j=((**j).n)* ;} /* error here */
(*a).len++;
*j=(struct elemento *)malloc(sizeof(struct elemento));
(**j).v=e;}
它在第 24 行和第 28 行代码中引发了两个错误,请帮助我
最佳答案
struct elemento ** j= ((*a).n)*; // 24th line
试试这个-
struct elemento ** j= & ((*a).n); // Note the removal of * and adding & symbol before.
由于j
是指向指针的指针,所以需要加上&
符号。
关于c - 我无法在 ‘;’ token 之前解决我的代码预期表达式中的此错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11764153/