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 array prblm

char array prblm

Scheduled Pinned Locked Moved C / C++ / MFC
data-structuresquestion
5 Posts 4 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.
  • U Offline
    U Offline
    User 589870
    wrote on last edited by
    #1

    hi, i have a char array in which i m getting path of current module.i want to convert it into string before loading it.hw can i do that?

    N _ B 3 Replies Last reply
    0
    • U User 589870

      hi, i have a char array in which i m getting path of current module.i want to convert it into string before loading it.hw can i do that?

      N Offline
      N Offline
      Nuri Ismail
      wrote on last edited by
      #2

      You actually asked this question 10 minutes ago in C# forum. If you want to convert char array to string in C++ you could use: 1) The constructor of std::string - here[^]. 2) The assignment operator of std::string - hete[^]. Example:

      const char* szChars = "ABCD";

      // Using constructor
      std::string strFromChars(szChars);

      // Using assignment operator
      std::string strFromChars;
      strFromChars = szChars;

      1 Reply Last reply
      0
      • U User 589870

        hi, i have a char array in which i m getting path of current module.i want to convert it into string before loading it.hw can i do that?

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

        char arr[MAX_PATH];
        std::string str = arr;

        OR

        wchar_t arr[MAX_PATH];
        std::wstring str = arr;

        OR

        TCHAR arr[MAX_PATH];
        CString str = arr;

        «_Superman_» I love work. It gives me something to do between weekends.
        Microsoft MVP (Visual C++)

        1 Reply Last reply
        0
        • U User 589870

          hi, i have a char array in which i m getting path of current module.i want to convert it into string before loading it.hw can i do that?

          B Offline
          B Offline
          BIJU Manjeri
          wrote on last edited by
          #4

          Which type of string you mean.? CString or std::string? for CString--- CString strPath(szPathName); for std::string-- const char* szPathName; std::string strPath; ... szPathName = "c:\\Test"; strPath = szPathName;

          U 1 Reply Last reply
          0
          • B BIJU Manjeri

            Which type of string you mean.? CString or std::string? for CString--- CString strPath(szPathName); for std::string-- const char* szPathName; std::string strPath; ... szPathName = "c:\\Test"; strPath = szPathName;

            U Offline
            U Offline
            User 589870
            wrote on last edited by
            #5

            thanx all and nuri ismail i mistakenly posted in c# forum i m doing it in vc++

            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