|  | 
 
| 我想在dos下获取系统的时间并给出判断:初始的时间是00:00:00;分钟数在5之内就是Fail的,其他则Pass。 我在TC2.0下调用函数gettime抓取时间,然后把分钟和小时分别赋给变量进行判断。(用U盘作的DOS)
 我搞不明白哪里有错误,批处理老是无法正确判断。
 请帮忙指点一下:是我哪里没弄明白搞错了。
 程序如下:
 #include <stdio.h>
 #include <dos.h>
 #include <stdlib.h>
 int main(void)
 {
 unsigned c_hour,c_min;
 int i_hour,i_min;
 struct time t;
 gettime(&t);
 printf("The current time is: %2d:%02d:%02d\n",t.ti_hour,t.ti_min,t.ti_sec);
 c_hour=t.ti_hour;
 c_min=t.ti_min;
 if(c_hour>0 || c_min>5)
 {
 return 0;
 printf("PASS\n");
 }
 else
 {
 return 1;
 printf("Fail\n")  }
 }
 
 然后调用这个文件写个批处理:
 @ECHO OFF
 CHKTIME.EXE              (上面那个文件)
 IF ERRORLEVEL 1 GOTO FAIL
 GOTO PASS
 
 :PASS
 CLS
 PASS.EXE
 PAUSE
 
 :FAIL
 CLS
 FAIL.EXE
 PAUSE
 rem GOTO FAIL
 | 
 |