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. Convert Byte[64] to CSTRIng

Convert Byte[64] to CSTRIng

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++graphics
8 Posts 5 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.
  • P Offline
    P Offline
    p_1960
    wrote on last edited by
    #1

    Hi, Please have a look std::vector Names; ENUMLOGFONTEX *lpelfe; Names.push_back(lpelfe->elfFullName); the above lines gives an error like.... error C2440: 'initializing' : cannot convert from 'BYTE [64]' to 'ATL::CStringT<BaseType,StringTraits>'with[BaseType=char, StringTraits=StrTraitMFC_DLL<char>] ] and please try to help regarding the same...

    N _ R 3 Replies Last reply
    0
    • P p_1960

      Hi, Please have a look std::vector Names; ENUMLOGFONTEX *lpelfe; Names.push_back(lpelfe->elfFullName); the above lines gives an error like.... error C2440: 'initializing' : cannot convert from 'BYTE [64]' to 'ATL::CStringT<BaseType,StringTraits>'with[BaseType=char, StringTraits=StrTraitMFC_DLL<char>] ] and please try to help regarding the same...

      N Offline
      N Offline
      norish
      wrote on last edited by
      #2

      What type of data do you want to push to std::vector? If you want CString, try

      std::vector Names;
      Names.push_back(new CString(lpelfe->elfFullName));

      or you do with BYTE[], try

      std::vector Names;
      BYTE* aName = new BYTE[sizeof(lpelfe->elfFullName)];
      memcpy(aName, lpelfe->elfFullName, sizeof(lpelfe->elfFullName);
      Names.push_back(aName);

      Do not forget delete elements after you dont need vector both above.

      N P 2 Replies Last reply
      0
      • P p_1960

        Hi, Please have a look std::vector Names; ENUMLOGFONTEX *lpelfe; Names.push_back(lpelfe->elfFullName); the above lines gives an error like.... error C2440: 'initializing' : cannot convert from 'BYTE [64]' to 'ATL::CStringT<BaseType,StringTraits>'with[BaseType=char, StringTraits=StrTraitMFC_DLL<char>] ] and please try to help regarding the same...

        _ Offline
        _ Offline
        _Superman_
        wrote on last edited by
        #3

        Your vector declaration cannot be seen in your posting. Is it declared std::vector<CString>?

        «_Superman_» I love work. It gives me something to do between weekends.

        P 1 Reply Last reply
        0
        • N norish

          What type of data do you want to push to std::vector? If you want CString, try

          std::vector Names;
          Names.push_back(new CString(lpelfe->elfFullName));

          or you do with BYTE[], try

          std::vector Names;
          BYTE* aName = new BYTE[sizeof(lpelfe->elfFullName)];
          memcpy(aName, lpelfe->elfFullName, sizeof(lpelfe->elfFullName);
          Names.push_back(aName);

          Do not forget delete elements after you dont need vector both above.

          N Offline
          N Offline
          norish
          wrote on last edited by
          #4

          disapeared template defs. :doh: first one is

          std::vector<CString*> Names;

          second one is

          std::vector<BYTE*> Names;

          1 Reply Last reply
          0
          • N norish

            What type of data do you want to push to std::vector? If you want CString, try

            std::vector Names;
            Names.push_back(new CString(lpelfe->elfFullName));

            or you do with BYTE[], try

            std::vector Names;
            BYTE* aName = new BYTE[sizeof(lpelfe->elfFullName)];
            memcpy(aName, lpelfe->elfFullName, sizeof(lpelfe->elfFullName);
            Names.push_back(aName);

            Do not forget delete elements after you dont need vector both above.

            P Offline
            P Offline
            Pavan_Putra
            wrote on last edited by
            #5

            I think , first Option should work. Bcoz while creating CString from Byte , you should say new() to it..

            It's not enough to be the best, when you have capability to be great...

            1 Reply Last reply
            0
            • _ _Superman_

              Your vector declaration cannot be seen in your posting. Is it declared std::vector<CString>?

              «_Superman_» I love work. It gives me something to do between weekends.

              P Offline
              P Offline
              p_1960
              wrote on last edited by
              #6

              ya it is declared..

              _ 1 Reply Last reply
              0
              • P p_1960

                ya it is declared..

                _ Offline
                _ Offline
                _Superman_
                wrote on last edited by
                #7

                Try a two step approach.

                std::vector<CString> Names;
                ENUMLOGFONTEX *lpelfe;
                CString str = lpelfe->elfFullName;
                Names.push_back(str);

                «_Superman_» I love work. It gives me something to do between weekends.

                1 Reply Last reply
                0
                • P p_1960

                  Hi, Please have a look std::vector Names; ENUMLOGFONTEX *lpelfe; Names.push_back(lpelfe->elfFullName); the above lines gives an error like.... error C2440: 'initializing' : cannot convert from 'BYTE [64]' to 'ATL::CStringT<BaseType,StringTraits>'with[BaseType=char, StringTraits=StrTraitMFC_DLL<char>] ] and please try to help regarding the same...

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

                  Can't you just use CString if you are already using MFC? Why do you have to use the std containers?!

                  It is a crappy thing, but it's life -^ Carlo Pallini

                  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