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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. to convert string^ to const char*

to convert string^ to const char*

Scheduled Pinned Locked Moved Managed C++/CLI
question
6 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.
  • M Offline
    M Offline
    mikobi
    wrote on last edited by
    #1

    I want to do that: par->Value = atof(this->taux->Text::get()); but it does n't work because atof(const char*) need that. What to do ?

    P M 2 Replies Last reply
    0
    • M mikobi

      I want to do that: par->Value = atof(this->taux->Text::get()); but it does n't work because atof(const char*) need that. What to do ?

      P Offline
      P Offline
      Programm3r
      wrote on last edited by
      #2

      This will work:String ^test = Text1->Text; char* var = (char*)Marshal::StringToHGlobalAnsi(test).ToPointer();


      The only programmers that are better than C programmers are those who code in 1's and 0's..... :) :)Programm3r My Blog: ^_^

      S M 2 Replies Last reply
      0
      • P Programm3r

        This will work:String ^test = Text1->Text; char* var = (char*)Marshal::StringToHGlobalAnsi(test).ToPointer();


        The only programmers that are better than C programmers are those who code in 1's and 0's..... :) :)Programm3r My Blog: ^_^

        S Offline
        S Offline
        Sivakumar R
        wrote on last edited by
        #3

        It is advisable to call Marshall::FreeHGlobalAnsi(IntPtr(var)); to clear the memory

        1 Reply Last reply
        0
        • P Programm3r

          This will work:String ^test = Text1->Text; char* var = (char*)Marshal::StringToHGlobalAnsi(test).ToPointer();


          The only programmers that are better than C programmers are those who code in 1's and 0's..... :) :)Programm3r My Blog: ^_^

          M Offline
          M Offline
          mikobi
          wrote on last edited by
          #4

          I try And i have this error : StringToHGlobalAnsi is not a member of Global Namespace I thing it need one include file. What is this header file ?

          Z 1 Reply Last reply
          0
          • M mikobi

            I want to do that: par->Value = atof(this->taux->Text::get()); but it does n't work because atof(const char*) need that. What to do ?

            M Offline
            M Offline
            MANISH RASTOGI
            wrote on last edited by
            #5

            Use this. double da = Double::Parse(String ^); Manish Rastogi

            1 Reply Last reply
            0
            • M mikobi

              I try And i have this error : StringToHGlobalAnsi is not a member of Global Namespace I thing it need one include file. What is this header file ?

              Z Offline
              Z Offline
              zybernau
              wrote on last edited by
              #6

              System.Runtime.InteropServices:cool:

              RaJ

              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