Hello everyone.

I'm a bit new to c++. I'm trying to write a game loop (see the code below) and I'm getting some weird behavior with the GetSystemTime().

I ran through it with the debugger and I get things like this:

startTime = 452

endTime = 210

And nothing seems to be over 1000 - so I figure that getSystemTime() literally only gets the time in milliseconds from the last second or something... Anyway, my question is - how the hell can I get the time?

void Game::Run()
	SYSTEMTIME systemTime;

	//framerate measuring
	char timerCount=0;
	long fpstimer=0;

	//work out the time each frame needs to take to keep fps
	long frameTime = 1000/this->fps;

		//get the frame start time
		long startTime = systemTime.wMilliseconds;

		//perform logic

		//perform rendering

		//get the frame end time
		long endTime = systemTime.wMilliseconds;

		//wait for the right time!
		long timeTaken = endTime - startTime;
		long waitTime = frameTime - timeTaken;
		if (waitTime > 0)

		//finally keep track of the fps by timing 100 frames
		if (timerCount > 100)
			long newfpstimer = systemTime.wMilliseconds;
			double actualFPS = (double)(newfpstimer - fpstimer)/(double)(timerCount*1000);
			printf("FPS: %f\n\n" , actualFPS);

			fpstimer = newfpstimer;
			timerCount = 0;
This question has already been answered. Start a new discussion instead.