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. Managed C++/CLI
  4. Convert System::String^ to char* array

Convert System::String^ to char* array

Scheduled Pinned Locked Moved Managed C++/CLI
questiondata-structures
4 Posts 3 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
    Manfr3d
    wrote on last edited by
    #1

    Hello guys, I want to read the content of a textbox (a path) and then edit a file at this path. The type of textbox->Text is System::String^ but file manipulating functions all need char* type parameters. How can I cast the text of the textbox into a char* variable, or are there newer functions than fopen(), fprintf() and so on, which work with managed type variables? Thanks and best wishes, Manfred

    L L 2 Replies Last reply
    0
    • M Manfr3d

      Hello guys, I want to read the content of a textbox (a path) and then edit a file at this path. The type of textbox->Text is System::String^ but file manipulating functions all need char* type parameters. How can I cast the text of the textbox into a char* variable, or are there newer functions than fopen(), fprintf() and so on, which work with managed type variables? Thanks and best wishes, Manfred

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi, in .NET you can do most of not all text processing using the String type; have a look at the File and/or FileInfo classes. :)

      Luc Pattyn [Forum Guidelines] [My Articles]


      Voting for dummies? No thanks. X|


      1 Reply Last reply
      0
      • M Manfr3d

        Hello guys, I want to read the content of a textbox (a path) and then edit a file at this path. The type of textbox->Text is System::String^ but file manipulating functions all need char* type parameters. How can I cast the text of the textbox into a char* variable, or are there newer functions than fopen(), fprintf() and so on, which work with managed type variables? Thanks and best wishes, Manfred

        L Offline
        L Offline
        leonigah
        wrote on last edited by
        #3

        array<wchar_t>^ szArray = strPath->ToCharArray(); char buffer[50]={0}; int i = 0; for each(wchar_t ch in szArray) buffer[i++] = ch;

        Nigah M Manzoor

        M 1 Reply Last reply
        0
        • L leonigah

          array<wchar_t>^ szArray = strPath->ToCharArray(); char buffer[50]={0}; int i = 0; for each(wchar_t ch in szArray) buffer[i++] = ch;

          Nigah M Manzoor

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

          Thanks, it's working now :)

          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