progs/C2a.c
changeset 211 e6e160c7ea33
parent 115 c4008b31df8e
child 216 38718062709a
--- a/progs/C2a.c	Mon Oct 06 02:44:23 2014 +0100
+++ b/progs/C2a.c	Mon Oct 06 20:52:53 2014 +0100
@@ -1,15 +1,17 @@
-// Since gets() is insecure and produces lots 
-// of warnings, thereofre I use my own input 
-// function instead.
-char ch;
-int i;
-
 void get_line(char *dst) {
   char buffer[8];
-  i = 0;
+  int i = 0;
+  char ch;
   while ((ch = getchar()) != '\n') {
-    buffer[i++] = ch; 
+    buffer[i++] = ch;
   }
   buffer[i] = '\0';
   strcpy(dst, buffer);
-}	
+}
+
+int match(char *s1, char *s2) {
+  while(*s1 != '\0' && *s2 != '\0' && *s1 == *s2){
+    s1++; s2++;
+  }
+  return( *s1 - *s2 );
+}