From: Myron Seto Newsgroups: comp.os.msdos.djgpp Subject: Question (beginner's): strptime Date: Thu, 23 Sep 1999 12:30:51 GMT Organization: Deja.com - Share what you know. Learn what you don't. Lines: 55 Message-ID: <7sd6hr$249$1@nnrp1.deja.com> NNTP-Posting-Host: 194.38.93.1 X-Article-Creation-Date: Thu Sep 23 12:30:51 1999 GMT X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows 98) X-Http-Proxy: 1.0 SICPASERVER05, 1.0 x28.deja.com:80 (Squid/1.1.22) for client 194.38.93.1 X-MyDeja-Info: XMYDJUIDmyron_seto To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Here's a program to calculate the number of days between two dates. But it won't compile because of "strptime" which is not defined in djgpp. Can someone help me to correct this problem? Thanks, myron_seto AT hotmail DOT com ---- #include #include #include const char *format = "%x"; const long secondsperday = (24 * 60 * 60); static char *program; void usage(void); int main(int argc, char *argv[]) { struct tm first, second; if ( NULL == (program = strrchr(argv[0], '/')) ) program = argv[0]; else program++; if ( 3 != argc ) { usage(); exit(1); } if ( NULL == strptime(argv[1], format, &first) ) { usage(); exit(1); } if ( NULL == strptime(argv[2], format, &second) ) { usage(); exit(1); } printf("%d\n", (mktime(&second) - mktime(&first)) / secondsperday); } void usage() { fprintf(stderr, "usage: %s %s %s\n", program, format, format); fprintf(stderr, "\t see man date for more info\n"); } Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't.