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. How to initialize _TCHAR array

How to initialize _TCHAR array

Scheduled Pinned Locked Moved C / C++ / MFC
data-structureshelptutorialquestion
3 Posts 2 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.
  • B Offline
    B Offline
    Boaz V
    wrote on last edited by
    #1

    Hi, i'm looking for a way to initialize a static array of _TCHAR elements. I've tried the following code in the StdAfx.h file. //BEGIN OF CODE static const _TCHAR * enDayOfWeek_DaysStrings[] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturady" }; //END OF CODE When _UNICODE is not defined, it works great. But when _UNICODE is defined, i get a compiler error: "error C2440: 'initializing' : cannot convert from 'const char [7]' to 'const _TCHAR *'. Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast" Any ideas?

    L 1 Reply Last reply
    0
    • B Boaz V

      Hi, i'm looking for a way to initialize a static array of _TCHAR elements. I've tried the following code in the StdAfx.h file. //BEGIN OF CODE static const _TCHAR * enDayOfWeek_DaysStrings[] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturady" }; //END OF CODE When _UNICODE is not defined, it works great. But when _UNICODE is defined, i get a compiler error: "error C2440: 'initializing' : cannot convert from 'const char [7]' to 'const _TCHAR *'. Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast" Any ideas?

      L Offline
      L Offline
      Laffis
      wrote on last edited by
      #2

      "" tells the compilter it is a non-unicode string. You should be using _T("Sunday"), or L"Sunday" if you are sure the application will be using unicode for certain.

      B 1 Reply Last reply
      0
      • L Laffis

        "" tells the compilter it is a non-unicode string. You should be using _T("Sunday"), or L"Sunday" if you are sure the application will be using unicode for certain.

        B Offline
        B Offline
        Boaz V
        wrote on last edited by
        #3

        Thanks. It was the correct way to do it (using the _T macro). anyhow, now i have another problem. i have double variables which i want to turn to strings. but the _GVCT function gets only 'char*' buffer. is there any _UNICODE replacement?

        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