programs/C2.c
changeset 198 2ce98ee39990
parent 197 9c968d0de9a0
child 199 20af800ce736
--- a/programs/C2.c	Sat Oct 04 12:46:04 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-// for installation notes see C0.c
-// this program can be called with
-//
-//  ./args2-good | ./C2
-//
-// or
-//
-// ./args2-bad | ./C2
-
-
-int match(char *s1, char *s2) {
-  while( *s1 != '\0' && *s2 != 0 && *s1 == *s2 ){
-    s1++; s2++;
-  }
-  return( *s1 - *s2 );
-}
-
-// since gets() is insecure and produces lots of warnings, 
-// I use my own input function instead ;o)
-char ch;
-int i;
-
-void get_line(char *dst) {
-  char buffer[8];
-  i = 0;
-  while ((ch = getchar()) != '\n') {
-    buffer[i++] = ch; 
-  }
-  buffer[i] = '\0';
-  strcpy(dst, buffer);
-}
-
-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();
-}
-