문제

I have an ulong value, how can i convert it to LPTSTR? I need to get LPTSTR value. (no printf)

Example code:

ULONG value = 1;
LPTSTR valueString = ???

Thanks!

도움이 되었습니까?

해결책

Use one of the _itoa() family of functions or StringCchPrintf(). The links go to the 'safe' versions of the functions, but the winapi also provides 'unsafe' and leagacy variants.

다른 팁

You can use itoa function, which is much simpler than sprintf, but may not be available in kernel.

If itoa is not available, you can recode it: itoa in GCC

You can't simply convert it. C just isn't so friendly.

You need to:
1. Get a large enough TCHAR array, where' you'd put the number. You can use a simple array on the stack (but it depends on what you want to do with it).
2. Convert the number to a printable representation in the buffer. _sntprintf can do this.
3. Use the address of this buffer.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top