Help With Homework Please

I need help, I have my code that is suppose to take the average of the first element in each arrays in a pointer. This is my assignment.

Given the following function declaration: float calculateAverage(vector *v). you are to calculate the average of var1’s in the vector array.

This is what I have so far.

float calculateAverage(vector *v)
{
int sum = 0;
int i;
for(i = 0; i = v->size; i++)
{
‍sum = v->array[i]->a + sum;
}
float average = sum/v->size;

return average;
}

For some reason I am receiving this:
vector.c:117:3: error: stray ‘\342’ in program
vector.c:117:3: error: stray ‘\200’ in program
vector.c:117:3: error: stray ‘\215’ in program

Can someone please help me or at least tell me what may cause these errors?
You have some characters in there that the compiler doesn't recognize.

I copied/pasted your code into a text file and opened it in a hex editor, and it appears that the problem is on this line:
/* some weird characters here*/sum = v->array[i]->a + sum;

Try deleting everything before "sum = ..." and reindenting that line and see if that helps.
Hi @romeoslaya,
i guess that here
is something wrong
for(i = 0; i = v->size; i++)
you are using the
assignment operator =
instead of <=
i think that this is
the problem if
i am missing something
let me know;


regards!
Thanks, Apparently there was some weird invisible characters that I wasn't able to see while working on a different computer. It was in the same line as long double main mentioned. Also eyenrique, I did end up having to change that operation as well. Thank you!
Topic archived. No new replies allowed.