printf("can't open file `%s'\n", argv[1]);
printf("%s: can't open file `%s'\n", argv[0], argv[1]);
int main(int argc, char** argv){  if (argc < 3) {    printf("usage:  %s input output\n", argv[0]);    exit(1);  }  FILE* input = fopen(argv[1], "rb");  if (input == NULL) {    printf("can't open file `%s'\n", argv[1]);    exit(2);  }  struct header {    int magic_number;    int version_number;    char filler[16];  } header;  EXIT_IF_FALSE(fread(&header, sizeof(header), 1, input) == 1);  EXIT_IF_FALSE(header.magic_number == 0x00051600);  EXIT_IF_FALSE(header.version_number <= 0x00020000);  // printf("sizeof(header) == %d\n", sizeof(header));  short entry_count;  EXIT_IF_FALSE(fread(&entry_count, sizeof(entry_count), 1, input) == 1);  struct entry {    unsigned int id;    unsigned int offset;    unsigned int length;  };  entry* entries = new entry[entry_count];  EXIT_IF_FALSE(fread(entries, sizeof(entry), entry_count, input) == entry_count);  entry* data_entry = NULL;  entry* rez_entry = NULL;  for (int i = 0; i < entry_count; i++) {    entry& entry = entries[i];    switch (entry.id) {    case 1:      // data fork.      data_entry = &entry;      break;    case 2:      rez_entry = &entry;      break;    }  }  const char* data_name = argv[2];  if (data_entry && data_entry->length) {    copy_range(input, data_entry->offset, data_entry->length, data_name);  } else {    // always create the data fork, even if the file doesn't have one.    FILE* tmp = fopen(data_name, "wb");    EXIT_IF_FALSE(tmp);    fclose(tmp);  }  if (rez_entry && rez_entry->length) {    char rez_name[512];    strcpy(rez_name, data_name);    strcat(rez_name, "/rsrc");    copy_range(input, rez_entry->offset, rez_entry->length, rez_name);  }  delete[] entries;  fclose(input);  return 0;}