1

I have been recently working on a program and i tried to use System::String^ to use it for an ofstream file...

I always get an Error... Note This is a Form so it is a Header File.

This is my Code...(one part)

System::String^ txtPath;

  #pragma endregion
private: System::Void btn1_Click(System::Object^  sender, System::EventArgs^  e) {
             using namespace std;
             ofstream fout (txtPath->c_str());
         }
private: System::Void txtBox1_TextChanged(System::Object^  sender, System::EventArgs^  e) {
             txtPath=(Convert::ToString(txtBox1->Text))+"\\weapon_deagle.txt";
         }

The Error I get is :

Error   1   error C2039: 'c_str' : is not a member of 'System::String'  c:\users\a\documents\visual studio 2010\projects\d1s1k formed\d1s1k formed\Form1.h

101
James McNellis
  • 348,265
  • 75
  • 913
  • 977
  • 2
    `System::String` does not have a `c_str` member function, which is what the error message states. If you need to convert the managed string into a character array, you can do it. [MSDN explains how.](http://msdn.microsoft.com/en-us/library/1b4az623.aspx) – James McNellis Mar 27 '12 at 20:19
  • @James McNellis Thank's but i think this is not what iwas looking for... You showd me the reverse mode i am looking :p – user1296520 Mar 27 '12 at 20:35
  • what are you trying to do? Why don't you use [FileStream](http://msdn.microsoft.com/en-us/library/system.io.filestream.aspx) instead of fout? – Botz3000 Mar 28 '12 at 06:58

0 Answers0