This code has no errors but then when i execute it, there is no output and the program automatically shuts down saying the program has stopped working.
#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(''," ");
if(i==3)
{
strcpy(currtime,timetoken);
}
}
printf("The current time is: %s
",currtime);
printf("We are waiting for: %s
",schedtime);
if(!strcmp(currtime,schedtime))
{
printf("Time to do stuff
");
system("C:PROJECT X");
}
getch();
return 0;
}
See Question&Answers more detail:os