这段代码没有错误,但是当我执行它时,没有输出,程序自动关闭,说程序已停止工作。
#include<unistd.h>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<string.h>
int main()
{
char *timetoken;
char currtime[7];
char schedtime[7];
int i;
struct tm *localtimeptr;
strcpy(schedtime,"15:25:00");
while(6!=9)
{
time_t lt;
sleep(1);
lt = time(NULL);
localtimeptr = localtime(lt);
timetoken=strtok(asctime(localtimeptr)," ");
for(i=1;i<5;i++)
timetoken=strtok('\0'," ");
if(i==3)
{
strcpy(currtime,timetoken);
}
}
printf("The current time is: %s\n",currtime);
printf("We are waiting for: %s\n",schedtime);
if(!strcmp(currtime,schedtime))
{
printf("Time to do stuff \n");
system("C:\PROJECT X");
}
getch();
return 0;
}