progs/C2b.c
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Wed, 26 Oct 2016 01:03:33 +0100
changeset 484 ddcc4ef4f82c
parent 472 d1da4bd4d7e9
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
472
d1da4bd4d7e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     1
void welcome() { printf("Welcome!\n"); exit(0); }
d1da4bd4d7e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     2
void goodbye() { printf("Wrong identity, exiting!\n"); exit(1); }
d1da4bd4d7e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     3
d1da4bd4d7e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     4
int main(){
d1da4bd4d7e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     5
  char name[8];
d1da4bd4d7e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     6
  char pw[8]; 
d1da4bd4d7e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     7
d1da4bd4d7e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     8
  printf("login: "); 
d1da4bd4d7e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     9
  get_line(name);
d1da4bd4d7e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    10
  printf("password: "); 
d1da4bd4d7e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    11
  get_line(pw);
d1da4bd4d7e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    12
d1da4bd4d7e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    13
  if(match(name, pw) == 0)
d1da4bd4d7e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    14
    welcome();
d1da4bd4d7e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    15
  else
d1da4bd4d7e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    16
    goodbye();
d1da4bd4d7e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    17
}