_ltoa(tmp, fps, 10);
That will place fps as a string in tmp. You could always use sprintf if you need extra info in there.
For the output, try a Sleep(15000); or something.
_ltoa(tmp, fps, 10);
That will place fps as a string in tmp. You could always use sprintf if you need extra info in there.
For the output, try a Sleep(15000); or something.
TCHAR szTempString[50];
wsprintf(szTempString, " %i frames per second", fps)
MessageBox(hwnd, szTempString, NULL, NULL);
the wsprintf() function is also unicode friendly if you're bracing for Windows 2000.
while(!kbhit()){}
kbhit is in conio.h
Josh
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
double fps;
double testnum;
unsigned long framecounter = 0;
double totaltime = 0;
long curtime = 0;
MessageBox(NULL, "To start click OK and wait 10 seconds.", "Windows Benchmark",MB_OK);
long starttime = GetTickCount();
while(curtime < 10000)
{
for(int res = 0; res < 65536; res++)
{
testnum = sqrt(2);
}
curtime = GetTickCount() - starttime;
framecounter++;
}
totaltime = (GetTickCount() - starttime)/1000;
fps = framecounter/totaltime;
TCHAR szTempString[50];
wsprintf(szTempString, " %i", fps);
MessageBox(NULL, szTempString, "Windows Benchmark, FPS:",MB_OK);
return 0;
}
(int) fps
or use %d instead of %i to indicate a double precision fp number.
If you do a google or altavista search on printf() you should be able to get a good list of how to format everything.
%f is typically used for double and floating-point.
"%04.1f" is one example that gives you 1 decimal point to the right of the decimal
Keeb
1) I have a double variable called fps. How can I display it as a string in the MessageBox function?
2) How do I keep a console app from closing immediately after it is over, I can't see my final output because the app closes. Thanks.