Le 28/05/11 21:28, Bill Cunningham a écrit :
I am trying here to calculate a mean of 3 values. I do not understand
the errors the compiler returned I've never seen them.
#include<stdio.h>
void mean(double *avg, int periods)
{
double val;
val = *avg / periods;
printf("%.2f\n", val);
}
int main(void)
{
double a[] = 2.2, 4.2, 5.00;
mean(a, 3);
}
p.c: In function `main':
p.c:12: invalid initializer
p.c:12: parse error before numeric constant
What's it trying to tell me?
Bill
Thanks a lot Bill.
For unknown reasons (normally I ignore your threads) I typed your code
and compiled it with lcc-win.
NO ERRORS.
WHAT?
Yes, lcc-win issued NO ERRORS AT ALL.
After a lot of work I found that I introduced a bug by eliminating a
call to "error" when after an equals sign in an array initialization
I do not find an opening brace.
Why did I do that?
Forgot, this bug is there since at least 3-4 years...
Well, thanks for your questions.
jacob