This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

declaration may not appear after executable statement

#include<lpc214x.h>
void init(void);
void delay_ms(int);
int main(void)
{ int i,j,k,A,B,C; IODIR0=0; A=0; B=IOPIN0; C=B^A; unsigned char c[]="I L*** NITC \n"; unsigned char r[]="I L*** EMBEDDED SYSTEMS \n"; if(C!=0) { init(); for(i=0;i<5;i++) { for(j=0;j<=12;j++) { U0THR=c[i]; while(U0LSR && 0x20); delay_ms(250); } } } else { init(); for(i=0;i<5;i++) { for(k=0;k<=24;k++) { U0THR=r[i]; while((U0LSR && 0x20)); delay_ms(100); } } }
} void init(void)
{ PINSEL0=0x5; U0FCR=0x7; U0LCR=0x83; U0DLL=0x62; U0DLM=0x0; U0LCR=0x3;
} void delay_ms(int x)
{ int a,b; for(a=0;a<x;a++) { for(b=0;b<3000;b++); }
} //////
THIS IS MY CODE FOR DISPLAYING FIRST STRING WHEN SWITCH IS PRESSED AND SECOND STRING WHEN SWITCH IS RELEASED.
nw_code.c(11): error: #268: declaration may not appear after executable statement in block unsigned char c[]="I L*** NITC \n";
nw_code.c(12): error: #268: declaration may not appear after executable statement in block unsigned char r[]="I L*** EMBEDDED SYSTEMS \n";
nw_code.c(60): warning: #1-D: last line of file ends without a newline

nw_code.c: 1 warning, 2 errors
".\disp_5.axf" - 2 Error(s), 1 Warning(s).

KINDLY SUGGEST ME A SOLUTION SOON