Guys, I got a new way to get system time. although its length is full of stupid work, but in this way you can get the system time in integer format.
#include <stdio.h> #include <stdlib.h> int main() { FILE *fp; char hc1,hc2,mc1,mc2; int hi1,hi2,mi1,mi2,hour,minute; system("echo %time% >time.txt"); fp=fopen("time.txt","r"); if(fp==NULL) exit(1) ; hc1=fgetc(fp); hc2=fgetc(fp); fgetc(fp); mc1=fgetc(fp); mc2=fgetc(fp); fclose(fp); remove("time.txt"); hi1=hc1; hi2=hc2; mi1=mc1; mi2=mc2; hi1-=48; hi2-=48; mi1-=48; mi2-=48; hour=hi1*10+hi2; minute=mi1*10+mi2; printf("Current time is %d:%d\n",hour,minute); return 0; }
p2013 Oct 31 '13 at 9:51 on 2013-10-31 09:51
source share