Exemple #1
0
int main(int argc, char** argv) {
	char *input = (char *)malloc(MAX_INPUT * sizeof(char));
	int i, command;

	initialize();
	for(;;) {

		fputs("Enter a command: ", stdout);
		fflush(stdout);
		fgets(input, MAX_INPUT, stdin);
		//printf("You entered: %s", input);

		// strip trailing newline
		if(input[strlen(input)-1] == '\n')
			input[strlen(input)-1] = '\0';

		command = parse_command(input);
		switch(command) {
			case 1: reset(); break;
			case 2: load(input); break;
			case 3: set(input); break;
			case 4: break_sc(input); break;
			case 5: step(); break;
			case 6: contin(); break;
			case 7: print(); break;
			case 8: script(input); break;
			case 9: return 1;
			default:
				printf("Unknown command: %s\n", input);
				break;
		}
	
	}
}
Exemple #2
0
void script(char *input) {
	char buf[MAX_INPUT];
	int command;

	FILE *fin = fopen(input+7, "r");
	if(fin == NULL) {
		printf("Invalid script file: %s\n", input+7);
		return;
	}
	while(fgets(buf, 50, fin) != NULL) {
		if(buf[strlen(buf)-1] == '\n')
			buf[strlen(buf)-1] = '\0';
		command = parse_command(buf);
		switch(command) {
			case 1: reset(); break;
			case 2: load(buf); break;
			case 3: set(buf); break;
			case 4: break_sc(buf); break;
			case 5: step(); break;
			case 6: contin(); break;
			case 7: print(); break;
			case 9: return;
			default:
				printf("Invalid command: %s\n", buf);
				break;
		}
	}
	fclose(fin);
}
Exemple #3
0
int main()
{
	int n;
	printf("Input size of field: ");
	scanf("%d", &n);
	int field[n][n];

	mixing(n, field);
	total(n, field);
	initscr();
	curs_set(0);
	start_color();
	init_pair(1, COLOR_BLACK, COLOR_YELLOW);
	attron(COLOR_PAIR(1));

	output_field(n, field, 0);
	contin(n, field);
	attroff(COLOR_PAIR(1));
	refresh();

	endwin();
	return 0;
}