Tuesday, 17 March 2009

String Compare strcmp

//Program to key in the password 3 times

#include
#include
#define mypassword "abc123"

void main()
{

char password [20] ;
int i ;

for( i=0; i <3; ++i)
{

printf("\nEnter security password : ");
gets(password);




if (strcmp(password,mypassword)==0)
{
printf("\nCorrect\n");
break;
}
}
if (i==3)
printf("\nYou have key in the password 3 time\n");
}

No comments: