progs/C2a.c
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Thu, 26 Nov 2015 11:59:38 +0000
changeset 436 8bf6704fc991
parent 216 38718062709a
permissions -rw-r--r--
update

int i;
char ch;  

void get_line(char *dst) {
  char buffer[8];
  i = 0;
  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){
    s1++; s2++;
  }
  return( *s1 - *s2 );
}