错误:预期')'前'*'令牌 [英] error: expected ‘)’ before ‘*’ token
本文介绍了错误:预期')'前'*'令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
#包括LT&;&stdio.h中GT;
结构S_ {
INT B:
}等;INT func1的(S ** SS){
* SS->一种= 10;
}
INT FUNC(S * T){
func1的(& T公司);
}
诠释主(){
是个;
FUNC(&放大器;一个);
的printf(\\ N A:%d个\\ N,A·B);
返回0;
}
试图示例程序,并得到一个错误的O / P。
O / P:
[根@ RSS]#GCC特区
特区:6:错误:预期')'前'*'令牌
特区:9:错误:预期')'前'*'令牌
特区:在函数'主':
直流转换:13:错误:预期';'前'一'
直流转换:14:错误:'A'未声明(在此函数第一次使用)
直流转换:14:错误:(每个未声明的标识符报道只有一次
直流转换:14:错误:它出现在每个功能)
解决方案
- 您省略了
的typedef
,你需要声明你的结构别名取值
。 - 结构体的成员是
B
,而不是A
。 - 您无法从你的函数返回任何东西。这些应该是无效的功能。
- 您需要大约
SS
括号中的FUNC1
。 - 无参数
主
在C
是INT主要(无效)
。
 
的#include<&stdio.h中GT;typedef结构{S_
INT B:
}等;无效func1的(S ** SS){
(* SS) - GT; B = 10;
}无效FUNC(S * T){
func1的(& T公司);
}INT主要(无效)
{
是个;
FUNC(&放大器;一个);
的printf(\\ n A·B:%d个\\ N,A·B);
返回0;
}
#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;
}
Trying the sample program and getting an error with the 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.)
解决方案
- You omitted the
typedef
that you need to declare your struct aliass
. - The struct's member is
b
rather thana
. - You failed to return anything from your functions. These should be void functions.
- You need parens around
ss
infunc1
. - The parameterless
main
inC
isint 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;
}
这篇关于错误:预期')'前'*'令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文