There's a problem using getch in the following program. I can't quite figure out how to take the input, compile and run it yourself, it was compiled with turbo c 2.01...so some of the includes might be different in other compilers. The two strings will never equal eachother...just take a look at the output of what you type when you run the program and you'll see what I mean. Thanks.
Code:#include <stdio.h> #include <conio.h> #include <string.h> #include <dos.h> #include <process.h> int i=0; int goAhead=1; int hackTry=0; char password[]="bcannadian"; char pword[50]; int main() { system("cls"); printf("Login V1.0\nCreated By Drew Peterson\n\n"); while(goAhead==1) { printf("Enter Password:"); for (i=0;i<50;i++) { pword[i]=getch(); if(pword[i]=='\r') { pword[i-1]='/0'; break; } fflush(stdin); /* printf("*");*/ printf(pword); } if(strcmp(password,pword)==0) { goAhead=0; } else { printf("Incorrect Password\n\n"); hackTry=hackTry+1; if(hackTry>=5) { printf("You Have Entered An Incorrect Password Too Many Times,\nPress Any Key To Reboot"); outportb(0xCF9,4); outportb(0xCF9,2); } } } printf("You Have Successfully Logged In\nPress Any Key To Continue\n"); getch(); execl("c:\\com.com",0); /*will only get to this point if it failed*/ printf("Failure To Load Operating System, Press Any Key To Reboot"); getch(); /*code to reboot*/ outportb(0xCF9,4); outportb(0xCF9,2); exit(0); }



LinkBack URL
About LinkBacks



