Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. char * to TCHAR

char * to TCHAR

Scheduled Pinned Locked Moved C / C++ / MFC
help
9 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Royaltvk
    wrote on last edited by
    #1

    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.

    CPalliniC C D 3 Replies Last reply
    0
    • R Royaltvk

      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.

      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #2

      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. :-D

      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

      In testa che avete, signor di Ceprano?

      R M 2 Replies Last reply
      0
      • R Royaltvk

        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.

        C Offline
        C Offline
        Cedric Moonen
        wrote on last edited by
        #3

        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]

        1 Reply Last reply
        0
        • CPalliniC CPallini

          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. :-D

          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

          R Offline
          R Offline
          Royaltvk
          wrote on last edited by
          #4

          Thank u somuch for your code It is perfectly working. U got my 5 Marks. Royal.

          CPalliniC 1 Reply Last reply
          0
          • R Royaltvk

            Thank u somuch for your code It is perfectly working. U got my 5 Marks. Royal.

            CPalliniC Offline
            CPalliniC Offline
            CPallini
            wrote on last edited by
            #5

            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

            In testa che avete, signor di Ceprano?

            R 1 Reply Last reply
            0
            • R Royaltvk

              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.

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              • CPalliniC CPallini

                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

                R Offline
                R Offline
                Rajesh R Subramanian
                wrote on last edited by
                #7

                I've balanced it up with my 5 vote. :)

                Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

                CPalliniC 1 Reply Last reply
                0
                • R Rajesh R Subramanian

                  I've balanced it up with my 5 vote. :)

                  Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

                  CPalliniC Offline
                  CPalliniC Offline
                  CPallini
                  wrote on last edited by
                  #8

                  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

                  In testa che avete, signor di Ceprano?

                  1 Reply Last reply
                  0
                  • CPalliniC CPallini

                    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. :-D

                    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

                    M Offline
                    M Offline
                    Mark Salsbery
                    wrote on last edited by
                    #9

                    CPallini 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:

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups