嗨我或多或少是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行代码中引发了两个错误,请帮助我
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
是指针指针,因此需要添加&
符号.