Click to See Complete Forum and Search --> : WHERE IS THE "PARSE ERROR" IN THESE 6 LINES


siqe
11-26-2000, 05:49 PM
void find_hi_lo(double averages[], double *lowest_average, double *highest_average)
{
*highest_average = 0;
*lowest_average = 200;
int x;

siqe
11-26-2000, 05:55 PM
gcc says its before int x;

siqe
11-26-2000, 05:59 PM
what the hell is this, i put the int x; before all the pointer crap and it works? why is that.

Mikenell
11-26-2000, 06:27 PM
Whats the exact error gcc gives?
Mikenell

Death on Wheels
11-26-2000, 06:33 PM
It looks like you left out the closing brace to close out the function, for starters.

------------------
Kurt Weber
Shell scripts? Shell scripts? We don't NEED no stinkin' shell scripts!
White, heterosexual, middle-class, and proud!
I've never understood why Bill Gates would name his company after his penis.

kervin
11-26-2000, 07:15 PM
I might be wrong, but try initializing x first then change the other variables.
C variables have to be declared before any other code.

void find_hi_lo(double averages[], double *lowest_average, double *highest_average)
{
int x;
*highest_average = 0;
*lowest_average = 200;

kervin
11-26-2000, 07:26 PM
Plus, why are you derefencing the pointers before changing them? You only should do that if you have 2 levels of indirection

eg. (forgive me, I don't have a compiler, but something like this should work)
double **a; /* a is a pointer to a pointer */
double c = 0.5
double *b = c; /* b points to c */

a = &b;
*a = 3.0

now the value in c should be 3.0 not 0.5

dunno
11-26-2000, 07:53 PM
In C you need to declare ALL variables at the beginning of a function, group of statements, etc.

------------------
"I'll get enough sleep when I'm dead."
--Left Behind, The Movie