--- a/progs/C2.c Mon Oct 06 02:44:23 2014 +0100
+++ b/progs/C2.c Mon Oct 06 20:52:53 2014 +0100
@@ -1,14 +1,32 @@
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+// Since gets() is insecure and produces lots
+// of warnings, thereofre I use my own input
+// function instead.
+void get_line(char *dst) {
+ char buffer[8];
+ int i = 0;
+ char ch;
+ while ((ch = getchar()) != '\n') {
+ buffer[i++] = ch;
+ }
+ buffer[i] = '\0';
+ strcpy(dst, buffer);
+}
+
int match(char *s1, char *s2) {
- while( *s1 != '\0' && *s2 != '\0' && *s1 == *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); }
+void welcome() { printf("Welcome!\n"); exit(0); }
+void goodbye() { printf("Wrong identity, exiting!\n"); exit(1); }
-main(){
+int main(){
char name[8];
char pw[8];
@@ -21,4 +39,4 @@
welcome();
else
goodbye();
-}
\ No newline at end of file
+}