모르는 함수를 찾아보는데 하루나 걸렸다.~cpp
#include <stdio.h>
#include <conio.h>
#include <time.h>
void main()
{
time_t record = 8;
time_t start_t;
start_t = time(0);
printf("wait 8 seconds...\n");
printf("and press any key exactly...");
for( ; ; )
{
if (kbhit()){
if(start_t - record == 0)
{
printf("You win !!\n");
}else{
printf("your time is off.");
}
break;
}
}
getch();
}
~cpp
#include <stdio.h>
#include <conio.h>
#include <time.h>
void main()
{
time_t record = 8;
time_t start_t;
start_t = time(0);
printf("wait 8 seconds...\n");
printf("and press any key exactly...");
for( ; ; )
{
if (kbhit()){
if(time(0) - start_t == record)
{
printf("You win !!\n");
}else{
printf("your time is off.");
}
break;
}
}
getch();
}
드디어 맞췄다! ㅎ~cpp
#include <stdio.h>
#include <conio.h>
#include <time.h>
void main()
{
time_t record = 8;
time_t start_t;
start_t = time(0);
printf("wait 8 seconds...\n");
printf("and press any key exactly...");
for( ; ; )
{
if (kbhit()){
if(time(0)-start_t == record-1 ) // 수정한 부분
{
printf("You win !!\n");
}else{
printf("your time is off.");
}
break;
}
}
getch();
}