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. .NET (Core and Framework)
  4. Char String to String ^ - Help Needed

Char String to String ^ - Help Needed

Scheduled Pinned Locked Moved .NET (Core and Framework)
c++helpcsharpquestionannouncement
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.
  • F Offline
    F Offline
    Freddie Code
    wrote on last edited by
    #1

    I'm using Visual C++ 2005 .NET. (I'm new to .Net programming) How do you convert a char string to a String ^ for printing in RichTextBox? Thanks. This is my code which does not work. char StringToDisplay[100] = {'\0'}; char StringToConcat[100] = {'\0'}; char chDllVersion[80]; // chDllVersion is returned from another function sprintf( StringToConcat, "dll version in use = %s ",chDllVersion); strcat( StringToDisplay, StringToConcat ); RichTextBox1->Text = StringToDisplay; // <- This gives an error because StringToDisplay Type is not of correct type

    L F N 3 Replies Last reply
    0
    • F Freddie Code

      I'm using Visual C++ 2005 .NET. (I'm new to .Net programming) How do you convert a char string to a String ^ for printing in RichTextBox? Thanks. This is my code which does not work. char StringToDisplay[100] = {'\0'}; char StringToConcat[100] = {'\0'}; char chDllVersion[80]; // chDllVersion is returned from another function sprintf( StringToConcat, "dll version in use = %s ",chDllVersion); strcat( StringToDisplay, StringToConcat ); RichTextBox1->Text = StringToDisplay; // <- This gives an error because StringToDisplay Type is not of correct type

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

      if this is about C++/CLI (i.e. the managed version of C++) you should use the string type, not char arrays; and ask in the C++/CLI forum. If you're new to .NET I strongly suggest you choose, buy and study an introductory text on the language of your choice. :)

      Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

      Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

      1 Reply Last reply
      0
      • F Freddie Code

        I'm using Visual C++ 2005 .NET. (I'm new to .Net programming) How do you convert a char string to a String ^ for printing in RichTextBox? Thanks. This is my code which does not work. char StringToDisplay[100] = {'\0'}; char StringToConcat[100] = {'\0'}; char chDllVersion[80]; // chDllVersion is returned from another function sprintf( StringToConcat, "dll version in use = %s ",chDllVersion); strcat( StringToDisplay, StringToConcat ); RichTextBox1->Text = StringToDisplay; // <- This gives an error because StringToDisplay Type is not of correct type

        F Offline
        F Offline
        Freddie Code
        wrote on last edited by
        #3

        I think I found a workable solution. I would not start a new project doing it this way but I'm working with some legacy code that is unmanaged so I need to deal with char arrays as string from C. To convert from char array to String in VS C++ .Net Managed Code use: gcnew System::String (YourCharArrayStringToDisplay); So for example, char ThingToShow[100] sprintf( ThingToShow, "This works!"); MessageBox::Show(gcnew System::String(ThingToShow)); Here is the link that I found it in: http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/adcadbc1-9092-41ba-8deb-01e800f0b172[^] :)

        1 Reply Last reply
        0
        • F Freddie Code

          I'm using Visual C++ 2005 .NET. (I'm new to .Net programming) How do you convert a char string to a String ^ for printing in RichTextBox? Thanks. This is my code which does not work. char StringToDisplay[100] = {'\0'}; char StringToConcat[100] = {'\0'}; char chDllVersion[80]; // chDllVersion is returned from another function sprintf( StringToConcat, "dll version in use = %s ",chDllVersion); strcat( StringToDisplay, StringToConcat ); RichTextBox1->Text = StringToDisplay; // <- This gives an error because StringToDisplay Type is not of correct type

          N Offline
          N Offline
          Nilesh G Umaretiya
          wrote on last edited by
          #4

          Try this code.......... This is for c# .......... RichTextBox1.Text = Convert.ToString(StringToDisplay);

          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