delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/02/05/16:09:22

From: Timo Saarinen <Timo DOT Saarinen AT uku DOT fi>
Newsgroups: comp.os.msdos.djgpp
Subject: uclock in Windows
Date: Wed, 05 Feb 1997 11:03:59 -0800
Organization: University of Kuopio / Library
Lines: 26
Message-ID: <32F8D99F.3A03@uku.fi>
Reply-To: Timo DOT Saarinen AT uku DOT fi
NNTP-Posting-Host: kryssi8.uku.fi
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hi,

I have tested the following program both in MS-DOS and Windows (3.11).
In DOS 
it works well but in Windows 'dt' variable gets frequently negative
values. 
Can some one tell me why this happens and is there any way to fix it?

#include <iostream.h>
#include <time.h>

void main (void)
{
  uclock_t t0 = uclock (), t;
  long dt;

  for (long i = 0; i < 100; i++) {
    t = uclock ();
    dt = t - t0;
    cout << " t0=" << (long) t0 << " t=" << (long) t << " dt=" << dt <<
endl;
    t0 = t;
  }
}

Timo DOT Saarinen AT uku DOT fi

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019