2012-06-24 3 views
-3

이 코드는 두 가지 오류가 있으므로 자동 작업 스케줄링을 실행하려면이 코드를 실행하고 싶습니다. 나는 정정을 알아낼 수 없다.작업 일정에 관한 코드

오류는 당신이 ... "(함수에서 '주')"

#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;      
}  
+0

있는 행에 오류 등이 줄 뭔가를 의미? –

+0

@OliCharlesworth : 18 번째 줄에 오류가 있습니다. – scheduling

+0

무엇을 시도 했습니까? 예를 들어, lvalue가 무엇인지에 대해 배우고 오류가 발생한 행에서 lvalue로 사용중인 것을 판별하고 유효한 lvalue인지 여부를 고려 했습니까? 또한 코드를 올바르게 포맷하십시오. –

답변

0

time = (&lt);

당신은 time라는 변수를 정의하지 않았다 "(할당에 잘못된 좌변)"및 이것이 다른 변수를 설정하기위한 것이 아니 었는지 확인하십시오.

+1

'while (6! = 9)'도 아주 이상하게 보입니다. 몇 번이나 확인해도 6은 결코 9가되지 않습니다! –

+0

: 나는이 링크를 여기 http://www.cplusplus.com/reference/clibrary/ctime/localtime/이라고 불렀고 코드를 작성했다. – scheduling

+0

괜찮 았지만, 어떻게 localtime이 작동하는지에 관계없이, 6은 항상 6이 될 것이다. 더 많지 않습니다. 'if (i == 3)'도 결코 참이되지 않습니다. –

0
time = (&lt); 

당신은 time에 할당 할 노력하고 있지만 자신은 time라는 것을 선언 한 적이 없다. 따라서 time(3)time.h에서 다시 할당하려고합니다.

은 아마 당신은

time(&lt);