progs/C2.c
changeset 105 40c51038c9e4
child 211 e6e160c7ea33
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/progs/C2.c	Mon Sep 30 23:57:44 2013 +0100
@@ -0,0 +1,24 @@
+int match(char *s1, char *s2) {
+  while( *s1 != '\0' && *s2 != '\0' && *s1 == *s2 ){
+    s1++; s2++;
+  }
+  return( *s1 - *s2 );
+}
+
+void welcome() { printf("Welcome to the Machine!\n"); exit(0); }
+void goodbye() { printf("Invalid identity, exiting!\n"); exit(1); }
+
+main(){
+  char name[8];
+  char pw[8]; 
+
+  printf("login: "); 
+  get_line(name);
+  printf("password: "); 
+  get_line(pw);
+
+  if(match(name, pw) == 0)
+    welcome();
+  else
+    goodbye();
+}
\ No newline at end of file