我无法在';'之前的代码预期表达式中解决此错误 代币

Alb*_*lla 0 c syntax-error

嗨我或多或少是c的新手,当我学习如何使用结构和联合时,我发现了这个错误:"预期的表达式';' 令牌"我一直在寻找错误,但我找不到它.我要问的是以下代码中需要的更正.

我在mac os x上使用Gnu C Compiler

#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;}
Run Code Online (Sandbox Code Playgroud)

它在第24和第28行代码中引发了两个错误,请帮助我

Mah*_*esh 5

struct elemento ** j= ((*a).n)*;   // 24th line
Run Code Online (Sandbox Code Playgroud)

试试这个 -

struct elemento ** j= & ((*a).n); // Note the removal of * and adding & symbol before.
Run Code Online (Sandbox Code Playgroud)

由于j是指针指针,因此需要添加&符号.

  • @AlbertoPerrella:很难,只是学习.每个人都从某个地方开始,即使是经验最丰富的人也会偶尔错过简单的事情. (2认同)