Type Conversion ?
-
Hi, This snippet in my program... USES_CONVERSION; LPCTSTR lpSource = _T("123456"); char szSource[10]; strncpy(szSource,W2A(lpSource),MAX_PATH); TRACE("%c",szSource[0]); When I do unicode build TRACE throws error C2664: 'AfxTrace' : cannot convert parameter 1 from 'char [3]' to 'const unsigned short *' Help me to solve this... :rolleyes:
-
Hi, This snippet in my program... USES_CONVERSION; LPCTSTR lpSource = _T("123456"); char szSource[10]; strncpy(szSource,W2A(lpSource),MAX_PATH); TRACE("%c",szSource[0]); When I do unicode build TRACE throws error C2664: 'AfxTrace' : cannot convert parameter 1 from 'char [3]' to 'const unsigned short *' Help me to solve this... :rolleyes:
Your application is UNICODE, you passed an ANSI string to the TRACE call. Do: TRACE(L"%c", ...); or TRACE(_T("%c"), ...); Roger Allen - Sonork 100.10016 Strong Sad: Clever I am? Next to no one. Undiscovered and soggy. Look up. Look down. They're around. Probably laughing. Still, bright, watery. Listed among the top. Ten. Nine. Late night. Early morn. Early mourn. Now I sleep.
-
Your application is UNICODE, you passed an ANSI string to the TRACE call. Do: TRACE(L"%c", ...); or TRACE(_T("%c"), ...); Roger Allen - Sonork 100.10016 Strong Sad: Clever I am? Next to no one. Undiscovered and soggy. Look up. Look down. They're around. Probably laughing. Still, bright, watery. Listed among the top. Ten. Nine. Late night. Early morn. Early mourn. Now I sleep.
Yep... it works... In the following... char str[][7] = {"123456", "789012", }; lstrlen(str[0]); under unicode build throws error C2664: 'lstrlenW' : cannot convert parameter 1 from 'char [7]' to 'const unsigned short *' How to handle this? :rolleyes:
-
Yep... it works... In the following... char str[][7] = {"123456", "789012", }; lstrlen(str[0]); under unicode build throws error C2664: 'lstrlenW' : cannot convert parameter 1 from 'char [7]' to 'const unsigned short *' How to handle this? :rolleyes:
Yep... I found it...its char str[][7] = {"123456", "789012", }; USES_CONVERSION; int val = lstrlen(A2W(str[0])); :)
-
Hi, This snippet in my program... USES_CONVERSION; LPCTSTR lpSource = _T("123456"); char szSource[10]; strncpy(szSource,W2A(lpSource),MAX_PATH); TRACE("%c",szSource[0]); When I do unicode build TRACE throws error C2664: 'AfxTrace' : cannot convert parameter 1 from 'char [3]' to 'const unsigned short *' Help me to solve this... :rolleyes:
Manikandan wrote: char szSource[10]; strncpy(szSource,W2A(lpSource),MAX_PATH); You've got a buffer overrun bug waiting to happen there. You have a 10-char array but you're telling strncpy that you have MAX_PATH chars available, which is 260. --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- "Linux is good. It can do no wrong. It is open source so must be right. It has penguins. I want to eat your brain." -- Paul Watson, Linux Zombie