| www.delorie.com/archives/browse.cgi | search |
| Xref: | news2.mv.net comp.os.msdos.djgpp:4646 |
| From: | fwk AT pacific DOT net DOT sg |
| Newsgroups: | comp.os.msdos.djgpp |
| Subject: | Re: Why doesnt this work! |
| Date: | Wed, 05 Jun 1996 11:26:00 GMT |
| Organization: | Pacific Internet, Singapore |
| Lines: | 52 |
| Message-ID: | <4p3uct$h50@raffles.technet.sg> |
| References: | <4p5btk$5ic AT news DOT cybermax DOT net> |
| NNTP-Posting-Host: | max85ppp32.pacific.net.sg |
| To: | djgpp AT delorie DOT com |
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
riggscl AT one DOT net (blah) wrote:
:>Can anyone tell me why this code doesnt work in djgpp.
:>#include <time.h>
:>#include <stdio.h>
:>#include <dos.h>
:>int main(void)
:>{
:> clock_t start, end;
:> start = clock();
:> delay(2000);
:> end = clock();
:> printf("The time was: %f\n", (end - start) / CLK_TCK);
:> return 0;
:>}
:>When i run this after compiling in gcc it always prints 0.00000!
:>I compiled it with -> gcc timer.c -otimer.exe
:>When i compile in borland c 3.1 or microsoft c 1.0 it works fine and give the
:>expected result(some floating point number - about 2.?????)
:>any ideas?
:>Chris Riggs
:>riggscl AT one DOT net
Try this
...
clock_t start, end;
double timetaken;
start = clock();
delay(2000);
end = clock();
timetaken=(end-start)/CLK_TCK;
printf("The time was: %f\n", timetaken);
...
It works for me. I guess somehow printf truncated the value.
Correct me if I am wrong.
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |