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