progs/C2a.c
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Mon, 06 Oct 2014 20:52:53 +0100
changeset 211 e6e160c7ea33
parent 115 c4008b31df8e
child 216 38718062709a
permissions -rw-r--r--
added files

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){
    s1++; s2++;
  }
  return( *s1 - *s2 );
}