// Create a new, empty table with same structure as an existing table

#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include "dbftable.h"

static char HELP[] =
  "\n"
  "dbfcopystruct  <existing table filepecs>  <new table filespecs>\n"
  "\n"
  "creates an empty dBase table with the same fields as those in\n"
  "an existing table.\n";


int main(int argc, char **argv)
{
  if (argc < 3)
  {
    puts(HELP);
    return 1;
  }
  dbf_table s;
  if (!s.open(argv[1], DBF_READ))
  {
    fprintf(stderr, "Can't open dBase table file %s\n", argv[1]);
    return 1;
  }
  dbf_table table;
  if (!table.open(argv[2], DBF_WRITE))
  {
    fprintf(stderr, "Can't open dBase table file %s\n", argv[2]);
    table.close();
    return 1;
  }
  table.copy_fields(s);
  table.close();
  return 0;
}


