You can define local variables in main, but they should be defined, such that they don't follow the variable assignment block or the code execution block.
This is a valid variable declaration/defintion in MPLAB C18:
void main ()
{
/* Declare or Define all Local variables */
unsigned char counter;
unsigned char count = 5;
/* Assignment Block or the code Execution Block starts */
conter++;
count++;
}
However, this isn't valid, and will cause a ‘Syntax Error’:
void main ()
{
/* Declare or Define all Local variables */
unsigned char count = 5;
/* Assignment Block or the code Execution Block starts */
count++;
/* What??? Another variable Declaration / Definition block */
unsigned char counter; /* Hmmm! Error: syntax error */
}
Hope that helps!