예제 #1
0
파일: io.c 프로젝트: keith-dev/openbsd
int
yesm(int x, int y, int z)	/* confirm with mspeak		*/
{
	int     result;
	int    ch;

	for (;;) {
		mspeak(x);	/* tell him what we want	*/
		if ((ch = getchar()) == 'y')
			result = TRUE;
		else if (ch == 'n')
			result = FALSE;
		else if (ch == EOF) {
			printf("user closed input stream, quitting...\n");
			exit(0);
		}
		if (ch != '\n')
			FLUSHLINE;
		if (ch == 'y' || ch == 'n')
			break;
		printf("Please answer the question.\n");
	}
	if (result == TRUE)
		mspeak(y);
	if (result == FALSE)
		mspeak(z);
	return (result);
}
예제 #2
0
파일: done.c 프로젝트: lattera/openbsd
void
done(int entry)		/* entry=1 means goto 13000 */	/* game is over */
			/* entry=2 means goto 20000 */	/* 3=19000 */
{
	int     i, sc;

	if (entry == 1)
		mspeak(1);
	if (entry == 3)
		rspeak(136);
	printf("\n\n\nYou scored %d out of a ", (sc = score()));
	printf("possible %d using %d turns.\n", mxscor, turns);
	for (i = 1; i <= clsses; i++)
		if (cval[i] >= sc) {
			speak(&ctext[i]);
			if (i == clsses - 1) {
				printf("To achieve the next higher rating");
				printf(" would be a neat trick!\n\n");
				printf("Congratulations!!\n");
				exit(0);
			}
			k = cval[i] + 1 - sc;
			printf("To achieve the next higher rating, you need");
			printf(" %d more point", k);
			if (k == 1)
				printf(".\n");
			else
				printf("s.\n");
			exit(0);
		}
	printf("You just went off my scale!!!\n");
	exit(0);
}