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

// in a parameter list, char s1[] means that s1 is a string
int begins(char s1[], char 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, char *argv[])
{
  // when you declare a variable, you can't declare char a[] without
  // specifying the length of the array, so you have to use the
  // (otherwise) equivalent char *a
  char *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);
}
