I have a problem compiling the following code:
#include <stdio.h>
#include <limits.h>
int main () {
printf("short: [%d,%d]\n",SHRT_MIN,SHRT_MAX);
printf("int: [%d, %d]\n",INT_MIN, INT_MAX);
printf("long: [%d, %d]\n",LONG_MIN,LONG_MAX);
int aa=017;
printf("%d\n",aa);
return 0;
}
Error message is:
1>c:\tic\ex1\ex2\ex2.c(12) : error C2143: syntax error : missing ';' before 'type'
1>c:\tic\ex1\ex2\ex2.c(13) : error C2065: 'aa' : undeclared identifier
However, compilation for this is fine:
#include <stdio.h>
#include <limits.h>
int main () {
int aa=017;
printf("short: [%d,%d]\n",SHRT_MIN,SHRT_MAX);
printf("int: [%d, %d]\n",INT_MIN, INT_MAX);
printf("long: [%d, %d]\n",LONG_MIN,LONG_MAX);
printf("%d\n",aa);
return 0;
}
Any idea what the issue is?
Visual Studio doesn't support C99 so all declarations (such as for
aa
in your example) in a block must appear before any statements (such as yourprintf
calls).