我什至不知道如何使這項工作! 所以我把這個東西寫在了正確的地方,在它要求輸入的部分,我什麼都不能輸入!請幫忙T_T 我在做什麼是一個問題&答案時間程序,用戶只能在限定的時間內回答問題。 這裏是我的代碼C無法在scanf中輸入
#include <stdio.h>
#include "engine.h"
void level2(){
system("cls");
printf("Level 2 \n\n\n");
timer();
if (time_limit >=0) {
printf("BOO");
}
}
int level1() {
char answer;
printf("Hello? \n\n");
scanf("%c",&answer);
time_limit = 20;
timer();
}
int rules() {
time_limit = 15;
system("cls");
printf(" Game Rules \n\n");
printf(" 1. You only have 5 seconds to guess what the correct answer for the question! \n");
}
int credits() {
int menu;
printf(" Coded by : \n");
printf("Lady Dianne Vertucci");
}
int main() {
int menu;
printf("TR \n ");
printf("1. Play \n");
printf("2. Credits \n");
scanf("%d",&menu);
switch (menu) {
case 1:
level1();
break;
case 2:
credits();
break;
default:
printf("Please choose a valid option 'tard");
break;
}
getch();
return 0;
}
這是engine.h
#ifndef _ENGINE_H_
#define _ENGINE_H_
static int time_limit = 0;
extern int time_limit;
static int score = 0;
extern int score;
int timer() {
while (time_limit !=0)
{
time_limit--;
printf("%02d\r",time_limit);
sleep(1000);
}
}
#endif
什麼是'time_limit'? – haccks
還介紹一下'engine.h'頭文件。 – haccks
已更新帖子 – xDianneCodex