progs/C2a.c
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Thu, 25 Jun 2015 00:04:46 +0100
changeset 373 bc612039d174
parent 216 38718062709a
permissions -rw-r--r--
updated

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 );
}