#include <stdio.h>
#include <stdlib.h>
#include <string.h>

// defining "string" to mean "char *" cleans up the code nicely
typedef char * string;

int begins(string s1, string s2)
{
  int i=0;

  while (1) {
    if (s1[i] == 0) return 1;
    if (s2[i] == 0) return 0;
    if (s1[i] != s2[i]) return 0;
    i++;
  }
  // can't get here
}

int main (int argc, string argv[])
{
  string a, b;
  int rval;

  if (argc < 3) {
    printf ("Usage: begins prefix word\n");
    exit(1);
  }

  a = argv[1];
  b = argv[2];
  rval = begins(a, b);
  printf ("%d\n", rval);
  exit (0);
}
