I am getting the syntax error message " ; before type char". I have searched high and low for a missing ";" but everything seems to be in the proper place. It is the last error in my program before a successful compilation.
Please Help!
Thanks!
Printable View
I am getting the syntax error message " ; before type char". I have searched high and low for a missing ";" but everything seems to be in the proper place. It is the last error in my program before a successful compilation.
Please Help!
Thanks!
Show us the code (using [code] tage (see my signature). Also what line is it giving the error on?
Ummm okay let me use my telepaty powers to c ur code throught ur mind !!!!! Post the code if u need a decent reply nun of use is harry porter u c
It's just a hunch, but see if this is what's wrong
Maybe that's it.Code:
#include <stdio.h>
int main(void)
{
int i;
i = 2;
printf("%d times %d is %d", i, i, i * i);
// uncomment int l = 6 and recompile as is
// int l = 6;
// Trying to create a variable here caused: 'syntax error : missing ';' before 'type'
// then try moving int l to the top and try it again.
return 0;
}
Thanks guys, my code was this:
void listrecords()
{fileptr=fopen("a:hospital", "r");
char option;
readfile();
.......
It finally dawned on me that my variables had to be declared first before opening the file. DUH!
Now my output has some garbage in it (not from the above problem) I will try to solve that problem tonight. I just stumbled on this board - it is great to know there are people out there who are willing to hear the drivel of a newbie.
Thanks!
The problem is you're trying to use C++ variable declaration in C.
int x = 1;
printf("%d", x );
The above is valid C code. The below is valid C++ code, and is not valid C code:
int x = 1;
printf("%d", x );
int y;
In C, all variable declaration must be at the beginning of the scope block.
Quzah.