i got error: "syntax error before 'for'" and I just don't understand why? Could you please explain why is that? I have few similar errors in code.
#define N 1024
void Reverse_Binary( double *a, unsigned long Len);
int main()
// here is error as well: error: syntax error before '{' token
{
//here are different variables for all code
buf = malloc(num_items*sizeof(double));
//here are different functions
Reverse_Binary(buf,N);
}
void Reverse_Binary( double *a,unsigned long Len)
{
long x, xprim;
int temp;
for (x=0; x<Len; x++)
{
xprim= rev(x,N);
if (xprim > x)
{
temp = a[x];
开发者_如何转开发 a[x] = a[xprim];
a[xprim] = temp;s
}
}
}
You missed the main closing bracket.
Put a bracket after:
Reverse_Binary(buf,N);
} //that's the missing bracket
Also remove the last bracket after Reverse_Binary function.
Check matching brackets first. When brackets go missing, compiler messages go seemingly awok because the code snippet looks right.
It looks OK, so the only idea I have that you have maybe invisible CR characters. Some compilers on Unix/Linux do not like files edited on Windows/DOS which contains CR/LF (0x0d, 0x0a) instead of LF (0x0a) as line delimiters. Try editing your file with vi and it may show the supplemental CR as ^M characters at the end of the line.
精彩评论