示例#1
0
int main(int argc, char **argv) {
	int c;
	FILE *fp;

	if (argv[0] && argv[0][0]) {
		prog = argv[0];
	}

	while ((c = getopt(argc, argv, "hc:e:f")) != -1) {
		switch (c) {
			case 'h':
				printf(
					"Usage: %s [OPTION...] [FILE]\n"
					"Options:\n"
					"  -h             print this help\n"
					"  -c NUMBER      specify cell size\n"
					"  -e NUMBER      specify EOF value\n"
					"  -f             enable autoflush\n"
					, prog
					);
				return EXIT_SUCCESS;

			case 'c':
				cellsize = strtoul(optarg, NULL, 0);
				break;

			case 'e':
				eof = strtol(optarg, NULL, 0);
				break;

			case 'f':
				setbuf(stdout, NULL);
				break;

			default:
				return EXIT_FAILURE;
		}
	}

	argc -= optind;
	argv += optind;

	if (!argv[0] || (argv[0][0] == '-' && argv[0][1] == '\0')) {
		fp = stdin;
	} else {
		if (!(fp = fopen(argv[0], "r"))) {
			die(argv[0]);
		}
	}

	return collect_input(fp);
}
int main(int argc, char* argv[]){
  Actor *lead_actor;
  Actor *test_actor;

  // exit if command line arguments are incorrect
	if(collect_input(argc, argv)) {
		printf("Exiting...\n");
		return 1;
	}

  lead_actor = actor_initialise_metaphor(choose_role);

	while (peek_next_id() <= initial_frog_count + cell_count){
    test_actor = actor_train_protege(lead_actor, choose_role(peek_next_id()), NULL);
  }
  perform(lead_actor); 
  actor_finalise_metaphor(lead_actor);
  return 0;
}