示例#1
0
文件: main.cpp 项目: reikimitsu/dam
int main(int argc, char *argv[]){

    print_question();
    if(calculate = 1){
	print_hello();
	return EXIT_SUCCESS;
    }
    else
	return EXIT_FAILURE;
}
示例#2
0
文件: Quiz.c 项目: Shoop123/Quiz-C
//the main quiz loop
void run_question_loop()
{
	int i; //interator
	
	//loops through each question and evaluates the answer
	for (i = 0; i < questions_amount; i++)
	{
		char answer[10]; /*stores answer of user*/
	
		//asks the question by printing it on the screen
		print_question(questions[i]);
		
		//prints choices for user
		print_answers(questions[i]);
		
		//prints "Answer"
		printf("Answer: ");
		
		//allows user to asnwer the  question, and stores the answer in the answer variable
		gets(answer);
		
		//stores the answer correctness result
		int answer_result = check_answer(answer[0], questions[i].answer);
		
		//checks the answer
		if (!answer_result)
		{
			//checks of the user inputted 'q' to quit
			check_quit(answer[0]);
			//make the question repeat
			i--;
			
			//loose a life
			lose_life(player);
		}
		
		//if this is the last question, then print "Great Job!" and the amount of lives
		if (i == questions_amount - 1)
		{
			printf("Great Job :)\n");
			printf("You ended with: %i lives!", player.lives);
		}
	}
}
示例#3
0
文件: tcl_cmd.c 项目: koodaamo/yadifa
static int
tcl_query(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[])
{
    u8 qname[MAX_DOMAIN_LENGTH];
    zdb_query_ex_answer answer;

    ya_result return_code;
    u16 qclass;
    u16 qtype;

    int argi = 1;

    if(FAIL(read_fdn(argv, argc, &argi, qname)))
    {
        return -1;
    }

    if(FAIL(read_classtype(argv, argc, &argi, &qclass, &qtype)))
    {
        return -2;
    }

    print_question((u8*)qname, qclass, qtype);

    zdb_query_ex_answer_create(&answer);
    
    if(FAIL(return_code = zdb_query_ex(&server_context->db_zdb, qname, qclass, qtype, &answer)))
    {
        fprintf(stdout, ERROR_CODE_HEX_DEC, return_code, return_code);
        fflush(stdout);

        return -3;
    }

    print_query_ex(&answer);

    zdb_query_ex_answer_destroy(&answer);

    fflush(stdout);

    return TCL_OK;
}