strange declaration error
hi
something very strange is happening, or im simply blind.
Code:
#include<stdio.h>
int main ()
{
printf("whats wrong?");
int i;
return 0;
}
my compiler doesnt compile it but says that the "Declaration is not allowed here in function main"
im using Borland C++ 5.5.1 for win32
whats wrong with this small code? why cant i declare variables in
main?
whaaa
You're declaring a variable
after you started the program.
You can declare a variable outside a function (global variable) or at the start of the function, look:
Code:
#include <stdio.h>
/* global var */
int iGlobal;
int main(void)
{
/* local var */
int iLocal;
return 0;
}