Click to See Complete Forum and Search --> : Printing the value of a variable on to a window


Fatboy
December 25th, 2004, 04:15 PM
Is there a windows.h function that prints the value of, say, x, onto the client area of a window? The TextOut only prints strings, but is there an equivilent for variables? I'm sure there is, but what is it?

NoHero
December 25th, 2004, 04:24 PM
Variables? What type? Integer? If so you can easily put strings together by using the _stprintf() function:


TCHAR szFull[256] = _T("");
TCHAR szTemp[10] = _T("");

int arr[] = { 3, 7, 1, 7, 9, 3, 8 };

for ( int i = 0; i < 7; i++ )
{
_stprintf(szTemp, _T("%d; "), arr[i]);
_tcscat(szFull, szTemp);
}
// Now print out the string by using TextOut()

Fatboy
December 25th, 2004, 06:04 PM
Sorry, I meant of type integer.

NoHero
December 26th, 2004, 05:46 AM
Sorry, I meant of type integer.

The easiest way of writing integer, floats etc. onto screen is to convert them into strings. And this conversion will be done by _stprintf().
I think you should post code showing us which type you want to print out.