Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6954511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:36:56+00:00 2026-05-27T14:36:56+00:00

I am trying to create a Windows Forms Application in Visual C++ 2010. I

  • 0

I am trying to create a Windows Forms Application in Visual C++ 2010. I have saved some particular string in string variable “stat” like:

System::String ^stat = "sample string";

The problem is, I cannot write it to a text file using ofstream. When I try this:

if ( opstat == true ) // opstat is a bool variable
{
    ofstream outf("mytxt.txt",ios::app);
    outf << stat;
    outf.close();
}

Compiler returns an error:

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

And a huge error that goes on forever like:

1>          D:\Development\Visual Studio 2010\VC\include\ostream(447): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(long double)'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>
1>          ]

What am I supposed to do here?

P.S. I have already included all necessary headers (or the ones I think are necessary) like string, fstream, istream, iomanip etc.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T14:36:57+00:00Added an answer on May 27, 2026 at 2:36 pm

    I think you have to convert System::String ^stat to std::string. See below link how to convert:

    C++/CLI Converting from System::String^ to std::string

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a text file in my Windows Forms application. It is
I've been trying to create a Windows Media Player plugin in Visual Studio 2008,
I have multiple business entities in VB.NET Windows Forms application. Right now they are
I'm trying to create a windows form application that manipulates data from several tables
In a Windows Form application, I'm trying to create a DataGridView with two columns:
I have created a C# Windows Forms application which I've attempted to make as
I'm developing a Windows Forms Application in Visual Basic .NET with Visual Studio 2008.
In a multi form .NetCF 3.5 application I'm trying create the forms in the
I'm trying to Remote Debugging a Windows Forms Application (C#), but i'm always getting
I'm a Silverlight/ASP.NET developer trying to write my first Windows Forms application to run

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.