编译器错误 - 帮助 [英] Compiler Error - help
问题描述
所以基本上我定义了一个结构如下:
struct speechSegment {
float coeff_Array [10] ;
浮动期;
浮动能量;
};
struct speechSegment segment = { / *我用info * /}填充这个结构;
以及稍后在我的main()中,我声明了一个名为coef [10]的静态数组,
并且基本上尝试将coef [10]的每个值分配给coeff_Array的相应
值
for(i = 0; i< Cmpst ; i ++){
coef [i] =(int)(segment.coeff_Array [i]); ----------->在这一行上获得
编译器错误
}
但是当我尝试编译时,我在前面提到的编译错误
行。
错误说错误:表达式必须有指向对象的类型
任何帮助为什么我得到这个错误将不胜感激..
谢谢,
Ravi
另请注意,coef是一个整数的数组,所以这就是为什么我给b
只是为了让你们知道...但我不是认为这就是为什么产生
错误
谢谢,
Ravi
>
ra**********@gmail.com 写道:< blockquote class =post_quotes>
所以我基本上按如下方式定义一个结构:
struct speechSegment {
float coeff_Array [10];
浮动周期;
浮动能量;
};
结构spe echSegment segment = {/ *我用info * /}填充这个结构;
然后在我的main()中,我声明了一个名为coef [10]的静态数组,基本上尝试将coef [10]的每个值分配给coeff_Array的相应值
(i = 0;我< CMPST; i ++){
coef [i] =(int)(segment.coeff_Array [i]); ----------->在这一行上得到编译错误
}
但是当我尝试编译时,我在前面提到的
行上出现编译错误。
错误说错误:表达式必须具有指向对象的指针类型
任何有关为什么我收到此错误的帮助将不胜感激..
谢谢,
请提供一个最小的例子 - 你的描述基本上是
没用:
以下
int main(无效)
{
struct speechSegment {
float coeff_Array [10];
浮动期;
浮动能量;
}段= {{-0.1F,1.0E4F,47.11F,0.F,0.F,
0.F,0.F,0.F,0.F,0.F},
3.141592654F,0.0F};
int i ;
static int coef [10];
for(i = 0; i< 10; i ++){
coef [i] = segment.coeff_Array [i];
}
返回0;
}
编译_and_适合您的描述ption。
您可能以错误的方式声明了coef。
请注意,施法可以掩盖错误;因此,使用尽可能少的演员阵容
。在这里,铸造是不必要的,可以省去。
如果你回答,请引用足够的背景 - 不是每个人
以相同的顺序获取每条消息或者根本。
干杯
Michael
-
电子邮件:我的是/ at / gmx / dot / de address。
对不起 - 好吧我想我不知道这个 - 你为什么宣称coef为
静态?
Ravi
Hi,
so basically I define a struct as follows:
struct speechSegment {
float coeff_Array[10];
float period;
float energy;
};
struct speechSegment segment = { /*I fill this struct with info */};
and later on in my main(), I declare a static array called coef[10],
and basically try to assign each value of coef[10] to the corresponding
value of coeff_Array
for(i = 0; i < Cmpst; i++) {
coef[i] = (int)(segment.coeff_Array[i]); -----------> Getting
compiler error on this line
}
But when I try to compile I get a compiler error on the aforementioned
line.
The error says "error: expression must have pointer-to-object type"
Any help as to why I''m getting this error will be appreciated..
Thanks,
Ravi
Also please note that coef is an array of ints, so thats why I
casted....just to let you guys know...but I don''t think thats why the
error is being generated
Thanks,
Ravi
ra**********@gmail.com wrote:Hi,
so basically I define a struct as follows:
struct speechSegment {
float coeff_Array[10];
float period;
float energy;
};
struct speechSegment segment = { /*I fill this struct with info */};
and later on in my main(), I declare a static array called coef[10],
and basically try to assign each value of coef[10] to the corresponding
value of coeff_Array
for(i = 0; i < Cmpst; i++) {
coef[i] = (int)(segment.coeff_Array[i]); -----------> Getting
compiler error on this line
}
But when I try to compile I get a compiler error on the aforementioned
line.
The error says "error: expression must have pointer-to-object type"
Any help as to why I''m getting this error will be appreciated..
Thanks,
Please provide a minimal example -- your description is essentially
useless:
The following
int main (void)
{
struct speechSegment {
float coeff_Array[10];
float period;
float energy;
} segment = { {-0.1F, 1.0E4F, 47.11F, 0.F, 0.F,
0.F, 0.F, 0.F, 0.F, 0.F},
3.141592654F, 0.0F};
int i;
static int coef[10];
for(i = 0; i < 10; i++) {
coef[i] = segment.coeff_Array[i];
}
return 0;
}
compiles _and_ fits your description.
You probably declared coef in the wrong way.
Note that casting can mask errors; therefore, use as few casts
as possible. Here, casting is unnecessary and can be left out.
If you answer, please quote enough context -- not everyone
gets every message in the same order or at all.
Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Sorry - OK I guess I don''t get this - why did you declare coef as
static?
Ravi
这篇关于编译器错误 - 帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!