错误:在'*'标记之前预期')'

Ang*_*gus -4 c

#include<stdio.h>
struct s_{
        int b;
}s;

int func1(s** ss){
        *ss->a = 10;
}
int func(s* t){
        func1(&t);
}
int main(){
        s a;
        func(&a);
        printf("\n a : %d \n",a.b);
        return 0;
}
Run Code Online (Sandbox Code Playgroud)

尝试示例程序并使用o/p获取错误.

O/P:

[root@rss]# gcc d.c
d.c:6: error: expected ‘)’ before ‘*’ token
d.c:9: error: expected ‘)’ before ‘*’ token
d.c: In function ‘main’:
d.c:13: error: expected ‘;’ before ‘a’
d.c:14: error: ‘a’ undeclared (first use in this function)
d.c:14: error: (Each undeclared identifier is reported only once
d.c:14: error: for each function it appears in.)
Run Code Online (Sandbox Code Playgroud)

Dav*_*nan 6

  1. 您省略了typedef声明结构别名所需的内容s.
  2. 结构的成员b而不是a.
  3. 您未能从函数中返回任何内容.这些应该是无效的功能.
  4. 你需要周围的括号ss在func1.
  5. 该参main在C为int main(void).

 

#include <stdio.h>

typedef struct s_{
        int b;
}s;

void func1(s** ss){
        (*ss)->b = 10;
}

void func(s* t){
        func1(&t);
}

int main(void)
{
        s a;
        func(&a);
        printf("\n a.b : %d \n", a.b);
        return 0;
}
Run Code Online (Sandbox Code Playgroud)