سؤال

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