Reputation: 31
This is my coding and I am getting the above error in the line where i declared int *intpointer. Please help me in solving this.
#include <stdio.h>
int main()
{
int intarray[5] = {10,20,30,40,50};
int i;
for(i = 0; i < 5; i++)
printf("intarray[%d] has value: %d - and address @ %x\n", i, intarray[i], &intarray[i]);
int *intpointer = &intarray[4];
printf("address: %x - has value %d\n", intpointer, *intpointer);
intpointer--;
printf("address: %x - has value %d\n", intpointer, *intpointer);
return 0;
}
Upvotes: 1
Views: 1336
Reputation: 310990
Place this declaration
int *intpointer = &intarray[4];
in the beginning of the function code block after the declaration of intarray
.
As error message reports you compile your code as C90 code that requires that declarations would be before other statements.
Upvotes: 2