tags:

views:

90

answers:

2

hai ..how to compare the two values ..like

TCHAR s[100];
CHAR d[100];

both varible have value .and how to compare the values..kindly help me.

+1  A: 

I would convert both values to the same type before attempting a compare.

BOOL UnicodeToAnsi(LPWSTR pszwUniString, LPSTR  pszAnsiBuff, DWORD  dwAnsiBuffSize){
int iRet = 0;
    iRet = WideCharToMultiByte(
 CP_ACP,
 0,
 pszwUniString,
 -1,
 pszAnsiBuff,
 dwAnsiBuffSize,
 NULL,
 NULL
 );
return ( 0 != iRet );

}

BOOL AnsiToUnicode(LPSTR  pszAnsiString, LPWSTR pszwUniBuff, DWORD dwUniBuffSize){

int iRet = 0;
    iRet = MultiByteToWideChar(
 CP_ACP,
 0,
 pszAnsiString,
 -1,
 pszwUniBuff,
 dwUniBuffSize
 );

return ( 0 != iRet );

}

Mick Walker
It's acceptable to convert `CHAR` to `TCHAR`.
xtofl
A: 

How about using lexicographical_compare and a function like

bool mycomp (TCHAR c1, char c2)
{ return tolower(c1)<tolower(c2); }
bool mycomp (char c1, TCHAR c2)
{ return tolower(c1)<tolower(c2); }
davidnr