i am working on following project. & its showing me some errors... & i am unable to remove them... please help me out...
program:-
/*HEADER FILES*/ #include<reg51.h> #include<string.h>
/*LCD PIN CONNECTIONS*/ #define lcd P0 sbit rs=P0^1; sbit en=P0^3;
/*LCD FUNCTIONS DECLARATIONS*/ void init_lcd(void); void cmd_lcd(unsigned char); void data_lcd(unsigned char); void str_lcd(unsigned char *); void Delay_ms(unsigned int);
/*KEYPAD PIN CONNECTIONS*/ sbit row0=P2^3; sbit row1=P2^5; sbit row2=P2^6; sbit row3=P2^0; sbit col0=P2^4; sbit col1=P2^2; sbit col2=P2^1;
/*MOTOR PIN CONNECTIONS*/ sbit M1=P1^0; sbit M2=P1^5;
/*BUZZER PIN CONNECTION*/ sbit BUZZER=P1^2;
/*VARIABLES DECLARATION*/ unsigned char i,j; unsigned char colval,rowval,pwdchange;
unsigned char pwd[15],temp[],str1[]="12345";
unsigned char keypad[4][3]={'1','2','3','4','5','6','7','8','9','*','0','#',}; /*PASSWORD FUNCTION DECLARATION*/ void password(void);
/*KEYPAD FUNCTION DECLARATION*/ unsigned char key(void);
/*MAIN FUNCTION*/ main() { unsigned char k=0; BUZZER=0; //BUZZER OFF M1=M2=0; //MOTOR OFF
init_lcd(); //LCD INITIALIZATION FUNCTION CALLING str_lcd("ENTER PASSWORD:"); //DISPLAY STRING ON LCD while(1) { cmd_lcd(0xc0); //2ND LINE DISPLAY password(); //PASSWORD FUNCTION CALLING if(pwdchange) { pwdchange=0; continue; } if(!strcmp(str1,pwd)) //COMPARING WITH 1ST PASSWORD { BUZZER=0; //BUZZER OFF cmd_lcd(0xc0); str_lcd("DOOR OPEN");
M1=0; //MOTOR RUNS IN FORWARD DIRECTION M2=1; Delay_ms(30); //30 MILLISECONDS DELAY cmd_lcd(0xc0); str_lcd(" "); M1=0; //MOTOR OFF M2=0; Delay_ms(1500);
cmd_lcd(0xc0); str_lcd("DOOR CLOSE");
M1=1; M2=0; Delay_ms(30); cmd_lcd(0xc0); str_lcd(" "); M1=0; //MOTOR OFF M2=0; k=0;
} else {
strcpy(temp,pwd); cmd_lcd(0x01); str_lcd("Confirm Password"); cmd_lcd(0xc0); password(); if(!strcmp(temp,pwd)) { strcpy(str1,temp); cmd_lcd(0x01); str_lcd("Password'Changed"); Delay_ms(1000); cmd_lcd(0x01); str_lcd("Enter Password"); cmd_lcd(0xc0); pwdchange=1; return; } else { cmd_lcd(0x01); str_lcd("Password Error"); Delay_ms(1000); cmd_lcd(0x01); str_lcd("Enter Password"); cmd_lcd(0xc0); pwdchange=1; return; } } else { cmd_lcd(0x01); str_lcd("Password Error"); Delay_ms(1000); cmd_lcd(0x01); str_lcd("Enter Password"); cmd_lcd(0xc0); pwdchange=1; return; } } else {goto label;
} else { goto label; }
else { label:pwd[i++]=j; data_lcd('*'); }
pwd[i]='\0'; }
//its showing 4 syntax error near else...
The goto statements are still there.
But now you have "introduced" a new version of C syntax:
... } else if <= if what? { cmd_lcd(0x01); ... }
Have you ever seen any text book describing any if statement that doesn't have a conditional expression? Exactly what would an "if" statement do, if you don't give it a condition?
Per Westermark
oh yeah!! now i got this... there should be some condition... in this syntax...
tell me the procedure to remove this errors from begining.. it will help me to understand the things.. because if i do that on myself , errors are increasing...:((( can i get your e-mail id??
can i get your e-mail id??
Please start reading this thread from the top. Stop after each entry and _think_ about what you read and what it says (about your abilities, not the posters!).
Already covered in one of the first posts of this thread.