char * to TCHAR
-
I have a function like this
BOOL CShowAndEditSQLDlg::IsSQLKeyword( CString strSQLWord ) { char * strKeyword[19] = { "SELECT", "FROM", "WHERE", "IN", "ORDER", "GROUP", "BY", "INNER", "OUTER", "JOIN", "AS", "ON", "MIN", "MAX", "AVG", "SUM", ",", "AND", "."}; for ( int i =0; i < 19; i++ ) if ( stricmp ( strKeyword[i], LPCTSTR(strSQLWord) ) == 0 ) return TRUE; return FALSE; }
But if I Compile that code with UNICODE settings, it is giving following error. error C2664: 'stricmp' : cannot convert parameter 1 from 'unsigned short *' to 'const char *' Please help me. -
I have a function like this
BOOL CShowAndEditSQLDlg::IsSQLKeyword( CString strSQLWord ) { char * strKeyword[19] = { "SELECT", "FROM", "WHERE", "IN", "ORDER", "GROUP", "BY", "INNER", "OUTER", "JOIN", "AS", "ON", "MIN", "MAX", "AVG", "SUM", ",", "AND", "."}; for ( int i =0; i < 19; i++ ) if ( stricmp ( strKeyword[i], LPCTSTR(strSQLWord) ) == 0 ) return TRUE; return FALSE; }
But if I Compile that code with UNICODE settings, it is giving following error. error C2664: 'stricmp' : cannot convert parameter 1 from 'unsigned short *' to 'const char *' Please help me.Royaltvk wrote:
error C2664: 'stricmp' : cannot convert parameter 1 from 'unsigned short *' to 'const char *'
Probably the error comes instead on parameter 2. Anyway, change your code as follows
BOOL CShowAndEditSQLDlg::IsSQLKeyword( CString strSQLWord )
{TCHAR * strKeyword[19] = { _T("SELECT"), _T("FROM"), _T("WHERE"), _T("IN"), _T("ORDER"), _T("GROUP"), _T("BY"),
_T("INNER"), _T("OUTER"), _T("JOIN"), _T("AS"), _T("ON"), _T("MIN"), _T("MAX"), _T("AVG"), _T("SUM"), _T(","), _T("AND"), _T(".")};for ( int i =0; i < 19; i++ )
if ( _tcsicmp ( strKeyword[i], LPCTSTR(strSQLWord) ) == 0 )
return TRUE;return FALSE;
}:) OT: sorry Mark no
GetBuffer
here. :-DIf the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke -
I have a function like this
BOOL CShowAndEditSQLDlg::IsSQLKeyword( CString strSQLWord ) { char * strKeyword[19] = { "SELECT", "FROM", "WHERE", "IN", "ORDER", "GROUP", "BY", "INNER", "OUTER", "JOIN", "AS", "ON", "MIN", "MAX", "AVG", "SUM", ",", "AND", "."}; for ( int i =0; i < 19; i++ ) if ( stricmp ( strKeyword[i], LPCTSTR(strSQLWord) ) == 0 ) return TRUE; return FALSE; }
But if I Compile that code with UNICODE settings, it is giving following error. error C2664: 'stricmp' : cannot convert parameter 1 from 'unsigned short *' to 'const char *' Please help me.To complete with the previous answer, you can also have a look at this article[^] if you want to understand a bit better why you have that compilation error.
Cédric Moonen Software developer
Charting control [v1.3] -
Royaltvk wrote:
error C2664: 'stricmp' : cannot convert parameter 1 from 'unsigned short *' to 'const char *'
Probably the error comes instead on parameter 2. Anyway, change your code as follows
BOOL CShowAndEditSQLDlg::IsSQLKeyword( CString strSQLWord )
{TCHAR * strKeyword[19] = { _T("SELECT"), _T("FROM"), _T("WHERE"), _T("IN"), _T("ORDER"), _T("GROUP"), _T("BY"),
_T("INNER"), _T("OUTER"), _T("JOIN"), _T("AS"), _T("ON"), _T("MIN"), _T("MAX"), _T("AVG"), _T("SUM"), _T(","), _T("AND"), _T(".")};for ( int i =0; i < 19; i++ )
if ( _tcsicmp ( strKeyword[i], LPCTSTR(strSQLWord) ) == 0 )
return TRUE;return FALSE;
}:) OT: sorry Mark no
GetBuffer
here. :-DIf the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke -
Actually I got
1
, anyway, you're welcome. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke -
I have a function like this
BOOL CShowAndEditSQLDlg::IsSQLKeyword( CString strSQLWord ) { char * strKeyword[19] = { "SELECT", "FROM", "WHERE", "IN", "ORDER", "GROUP", "BY", "INNER", "OUTER", "JOIN", "AS", "ON", "MIN", "MAX", "AVG", "SUM", ",", "AND", "."}; for ( int i =0; i < 19; i++ ) if ( stricmp ( strKeyword[i], LPCTSTR(strSQLWord) ) == 0 ) return TRUE; return FALSE; }
But if I Compile that code with UNICODE settings, it is giving following error. error C2664: 'stricmp' : cannot convert parameter 1 from 'unsigned short *' to 'const char *' Please help me.Is
IsSQLKeyword()
called often?"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
Actually I got
1
, anyway, you're welcome. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain ClarkeI've balanced it up with my 5 vote. :)
Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP
-
I've balanced it up with my 5 vote. :)
Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP
Ah, were you, thanks buddy! :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke -
Royaltvk wrote:
error C2664: 'stricmp' : cannot convert parameter 1 from 'unsigned short *' to 'const char *'
Probably the error comes instead on parameter 2. Anyway, change your code as follows
BOOL CShowAndEditSQLDlg::IsSQLKeyword( CString strSQLWord )
{TCHAR * strKeyword[19] = { _T("SELECT"), _T("FROM"), _T("WHERE"), _T("IN"), _T("ORDER"), _T("GROUP"), _T("BY"),
_T("INNER"), _T("OUTER"), _T("JOIN"), _T("AS"), _T("ON"), _T("MIN"), _T("MAX"), _T("AVG"), _T("SUM"), _T(","), _T("AND"), _T(".")};for ( int i =0; i < 19; i++ )
if ( _tcsicmp ( strKeyword[i], LPCTSTR(strSQLWord) ) == 0 )
return TRUE;return FALSE;
}:) OT: sorry Mark no
GetBuffer
here. :-DIf the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain ClarkeCPallini wrote:
OT: sorry Mark no GetBuffer here.
Hehe I can't believe that caught my eye when I glazed over your post ;P
Mark Salsbery Microsoft MVP - Visual C++ :java: