The buffer in your function only needs to be 35 chars long as thats the max length of taunts in Debug more, or 20 in normal..
Good idea about code snippets, so i'm putting in my timer class. I use it alot, its not very accurate, only using GetTickCount(), but its a start and can be modified and done alot better. Here it is:
header file:
#include <windows.h>class CTimer {public: CTimer(); virtual ~CTimer(); int GetTime(); void Reset(); int Stop(); void Start(); bool IsTiming() { return IsTiming; } int Time;private: int EndTick; int StartTick; bool Timing;};
and cpp file:
CTimer::CTimer(){ Reset(); //Reset to 0. Timing = false;}CTimer::~CTimer(){}void CTimer::Start(){ StartTick = GetTickCount(); //Store current Tick Count in StartTick. Timing = true;}int CTimer::Stop(){ if(StartTick == 0) { return 0; } EndTick = GetTickCount(); //Store TickCount in EndTick. Timing = false; Time+=(EndTick - StartTick); return EndTick - StartTick; //Return Time.}void CTimer::Reset(){ if(Timing) //If the timer is still active, stop timing { Stop(); } StartTick = 0; //Reset values to 0. EndTick = 0; Time = 0;}int CTimer::GetTime(){ if(StartTick == 0) { return 0; } int tmpTick = GetTickCount(); return tmpTick - StartTick;}
Like I say it could probably be done better, but my little contribution..
Heres a comment/documentation paragraph i wrote, so i'm not sure if it makes sence, i can read it..
![](smile.gif)
To time, user must call the Start() function. When user wishes to stop timing call the Stop() function.Stop will return the time interval counted, however, the user can access this at a later time throughthe public variable Time. Reset() resets the timing values (including Time) to 0. If the user should start timing again without calling Reset(), then the time will be added to the last time interval.Use the GetTime() function to get the time without interupting timing. Use this to display live datafrom the timer with out stopping it.
EDIT: Changed code so it would work with modification i made before I posted.
-J
[edited by - jason2jason on August 4, 2003 5:27:07 PM]