CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2010
    Posts
    10

    writing a string to a text file

    hello, I am using visual c++ 2005 and I am trying to take a value that a user selects on a combo box and then output it to a file, but with the code I have it seems I cannot output a string to a file as it has to be a char

    how can you get around this?

    String^ alert = alertbox->Text;
    ofstream file("file.txt");
    file << alert;


    compile error:

    error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'System::String ^' (or there is no acceptable conversion)

    thanks!
    Reply With Quote

  2. #2
    Join Date
    Feb 2005
    Posts
    2,160

    Re: writing a string to a text file

    Try the Managed C++ forum.

  3. #3
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: writing a string to a text file

    [ moved thread ]
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured