I want to turn int value to char *p;
and I have tried itoa,
but it can not be passed building.
How to turn int value to char *p,
Thank you
I want to turn int value to char *p;
and I have tried itoa,
but it can not be passed building.
How to turn int value to char *p,
Thank you
itoa
tanzirmusabbir
hi avinash
What different about TCHAR and char
Thank
Tom Phillips
char buf [16];
int value = 1234;
itoa(value, buf, 10);
Or to prevent the VS2005 compiler bitching about unsafe code:
char buf [16];
int value = 1234;
itoa_s(value, buf, 16, 10);
SteveHopwood1
hi nobugz:
my codes below:
char str[20];
itoa(total_pc,str,10);
GetDlgItem(IDC_EDIT2)->SetWindowText(str);
the total_pc is int value, which define at .h file int total_pc;
the error is below:
error C3861: 'itoa': identifier not found
error C2664: 'CWnd::SetWindowTextW' : cannot convert parameter 1 from 'char [20]' to 'LPCTSTR'
nwave
One way to quickly find out what functions are available is just search for them.
C:\Program Files\Microsoft Visual Studio 8\SmartDevices\SDK\PocketPC2003\Include>findstr itoa *
stdlib.h:char * __cdecl _itoa(int, char *, int);
tchar.h:#define _itot _itoa
This tells you that you can use _itoa if you add #include <stdlib.h>
Brian
dazza33
Dear brian:
Thank you
I code below
char str[20];
_itoa(total_pc,str,10);
GetDlgItem(IDC_EDIT2)->SetWindowText(str);
the _itoa() has passed the building
but SetWindowText() error
the system tell me that
error C2664: 'CWnd::SetWindowTextW' : cannot convert parameter 1 from 'char [20]' to 'LPCTSTR'
How to do that
bill
celinedrules
I just use sprintf for all my conversions to strings. To be more specific, I use _snprintf as it is safer. There are also versions of these for W and T. I personally just use normal char's, then convert with CA2W(), which will convert a char to a WCHAR. I do this because the only time I need WCHAR is for MessageBox, the rest of the time I need the char*.
Simon_X
char - 8 bit none Unicode characters. Never use that on CE with OS API.
TCHAR - 8 or 16 bit Unicode or none Unicode characters, depends on some macros. TCHAR is always 16 bit Unicode on CE.
WCHAR - 16 bit Unicode. It’s a good idea to use that all the time.
So, you have type mismatch because you're trying to pass none Unicode string to Unicode API. You should use Unicode string and Unicode version of atoi() to fix that. You can look up versions of atoi() on MSDN.
Dr. Chris
There is a very small set of functions that work with chars on devices. You should be using their wchar_t counterparts, or better still the TCHAR functions.
Try the following code.
TCHAR str[20];
::_itot_s(10,str,20,10);
Since this is a ATL/MFC project I think Checked::itot_s should also be available to you.
Hope this helps.
Thanks