I'm not having this problem. When I wrote int i, there was an error that i was defined before being initialized. I actually tried to fix the code with the comments written here, and I still had the same error. Apparently, there's a system error, not a code error. I sent the code to a friend, who ran the code on his computer, and he didn't have any problems, despite the fact that he didn't change the code at all.
When I wrote int i, there was an error that i was defined before being initialized.
Maybe this following code is a bit pedantic, but it should always work. I would be upset if it doesn't because that is C style that has been around forever.
1 2
int i = 0; //declare and initialise
for (i=0; i<n; ++i) //notice dont specify int again
Maybe you should post the exact compiler output?
I sent the code to a friend, who ran the code on his computer, and he didn't have any problems, despite the fact that he didn't change the code at all.
That implies different compiler settings - a system error as you say. We would need to know lots about your system to fix that. The compiler & version, the compiler flags, maybe the compile command being used. Some of this we could see from the compiler output.