-3

我想执行这段代码来运行自动任务调度,因为这段代码有两个错误。我无法弄清楚更正。

错误是“(在函数'main'中)”和“(赋值中的左值无效)”

#include<unistd.h>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<string.h>

int main()
{
    char *timetoken;
    char currtime[7];
    char schedtime[9];
    int i;
    struct tm *localtimeptr;
    strcpy(schedtime,"15:25:00");
    while(true)
    {
        time_t lt;
        sleep(1);
        time(&lt);
        localtimeptr = localtime(&lt);
        timetoken=strtok(asctime(localtimeptr)," ");
        for(i=1;i<5;i++)
            timetoken=strtok(NULL," ");
        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("ROBOCOPY C:\\oslab E:\\BACKUP /e/mir/np /log:backup_log.txt");
    }        
    getch();
    return 0;                      
}     
4

2 回答 2

0

time = (&lt);

您没有定义一个名为time... 的变量,您确定这不是要设置不同的变量吗?

于 2012-06-24T22:29:33.750 回答
0
time = (&lt);

您正在尝试分配 to time,但您自己从未声明过任何名为time. 因此,您尝试从 重新time(3)分配time.h

也许你在这一行中的意思是别的东西,比如

time(&lt);
于 2012-06-24T22:30:12.167 回答