does declare variables must before functionary code in VS2005 using C language?
-
example1, this is OK.
#include int main(void) { int n = 5; int m = 6; printf("%d\n", n+m); }
example2, error :(#include int main(void) { int n = 5; int m = 6; printf("%d\n", n+m); int z = 9; // error here, error C2143: syntax error : missing ';' before 'type' }
is there a compile options for allow declare variables after functionary code in VS2005 IDE ?? :rose::rose::rose:Glad to discuss with you and best wishes.
-
example1, this is OK.
#include int main(void) { int n = 5; int m = 6; printf("%d\n", n+m); }
example2, error :(#include int main(void) { int n = 5; int m = 6; printf("%d\n", n+m); int z = 9; // error here, error C2143: syntax error : missing ';' before 'type' }
is there a compile options for allow declare variables after functionary code in VS2005 IDE ?? :rose::rose::rose:Glad to discuss with you and best wishes.
Yes VC++ do allow to put variables anywhere within function body. You are getting this error because you are compiling this code from a .c file. In C variables are allowed only at the begining of a function. Just change the file extension from c to cpp and it will compile. -Saurabh