progs/C2.c
changeset 105 40c51038c9e4
child 211 e6e160c7ea33
equal deleted inserted replaced
104:729b86eae005 105:40c51038c9e4
       
     1 int match(char *s1, char *s2) {
       
     2   while( *s1 != '\0' && *s2 != '\0' && *s1 == *s2 ){
       
     3     s1++; s2++;
       
     4   }
       
     5   return( *s1 - *s2 );
       
     6 }
       
     7 
       
     8 void welcome() { printf("Welcome to the Machine!\n"); exit(0); }
       
     9 void goodbye() { printf("Invalid identity, exiting!\n"); exit(1); }
       
    10 
       
    11 main(){
       
    12   char name[8];
       
    13   char pw[8]; 
       
    14 
       
    15   printf("login: "); 
       
    16   get_line(name);
       
    17   printf("password: "); 
       
    18   get_line(pw);
       
    19 
       
    20   if(match(name, pw) == 0)
       
    21     welcome();
       
    22   else
       
    23     goodbye();
       
    24 }