title: visual c++ fstream error
body: <p>first of all I'm a hardware programmer (HDL, uC programming) and was asked by my boss a couple of days ago to create an Interface in visual C++ to control a uC. I never used visual C++ before and my software programming skills are intermediate at best. However, I only have till Tuesday to get the interface to work, therefore I had to look for examples and do the same, due to the time frame I have. So please excuse me if I ask any obvious and stupid questions.</p>
  
  <p>In my code, I have to move values stored in an array to a CSV file. So I have to separate my values using commas... 
  However, in order to create a CSV file, I have to use fstream (as far as I understood from what I've read so far).
  Whenever I use </p>
  
  <pre><code>#include &lt;fstream&gt;
  </code></pre>
  
  <p>I get a huge amount of errors such as:</p>
  
  <pre><code>1&gt;c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(244): error C3083: 'vc_attributes': the symbol to the left of a '::' must be a type
  1&gt;c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(244): error C2039: 'YesNoMaybe' : is not a member of '`global namespace''
  </code></pre>
  
  <p>Here is the rest of my code related to fstream:</p>
  
  <pre><code>using namespace System;
  using namespace System::ComponentModel;
  using namespace System::Collections;
  using namespace System::Windows::Forms;
  using namespace System::Data;
  using namespace System::Drawing;
  using namespace System::IO::Ports;
  #include &lt;iostream&gt;
  #include &lt;fstream&gt;
  
        std::ofstream myfile;
              myfile.open("Data.txt");
              //find available ports
              private: void findports(void){
                           array&lt;Object^&gt;^ objectArray = SerialPort::GetPortNames();
                           this-&gt;comboBox4-&gt;Items-&gt;AddRange( objectArray );
                           array&lt;String ^&gt; ^ h = gcnew array&lt;String ^&gt;(24);
                           for(int i=0; i&lt;=23; i++){
                               h[i]= String::Concat(i.ToString());
                           }
                           this-&gt;comboBox1-&gt;Items-&gt;AddRange( h );
                            array&lt;String ^&gt; ^ m = gcnew array&lt;String ^&gt;(60);
                           for(int i=0; i&lt;=59; i++){
                               m[i]= String::Concat(i.ToString());
                           }
                           this-&gt;comboBox3-&gt;Items-&gt;AddRange( m );
                            array&lt;String ^&gt; ^ s = gcnew array&lt;String ^&gt;(24);
                           for(int i=0; i&lt;=23; i++){
                               s[i]= String::Concat(i.ToString());
                           }
                           this-&gt;comboBox5-&gt;Items-&gt;AddRange( s );
                            array&lt;String ^&gt; ^ d = gcnew array&lt;String ^&gt;(366);
                           for(int i=0; i&lt;=365; i++){
                               d[i]= String::Concat(i.ToString());
                           }
                           this-&gt;comboBox2-&gt;Items-&gt;AddRange( d);
                       }
  
  
  
  
  
  
  
  
          private: System::Void label1_Click(System::Object^  sender, System::EventArgs^  e) {
                   }
          private: System::Void label2_Click(System::Object^  sender, System::EventArgs^  e) {
                   }
      private: System::Void label4_Click(System::Object^  sender, System::EventArgs^  e) {
               }
      private: System::Void label5_Click(System::Object^  sender, System::EventArgs^  e) {
               }
      private: System::Void label6_Click(System::Object^  sender, System::EventArgs^  e) {
               }
      private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
  
                   if((this-&gt;comboBox4-&gt;Text == String::Empty)||(this-&gt;textBox1-&gt;Text == String::Empty)||(this-&gt;textBox2-&gt;Text == String::Empty)){
                       this-&gt;textBox1-&gt;Text="missing port settings";
                       this-&gt;textBox2-&gt;Text="missing port settings";
                   }
                   else{ // start assigning
                       try{ // first make sure port isn't busy/open
                           if(!this-&gt;serialPort1-&gt;IsOpen){
                               // select the port whose name is in comboBox4 (select port)
                               this-&gt;serialPort1-&gt;PortName=this-&gt;comboBox4-&gt;Text;
                               //open the port
                               this-&gt;serialPort1-&gt;Open();
  
  
                               // sending
                               String^ name_ = this-&gt;serialPort1-&gt;PortName;
                               String^ sampling_period_ = this-&gt;comboBox5-&gt;Text;
  
                               String^ days_ = this-&gt;comboBox2-&gt;Text;
  
                               String^ hours_ = this-&gt;comboBox3-&gt;Text;
  
                               String^ minutes_ = this-&gt;comboBox1-&gt;Text;
  
                               String^ start_ = this-&gt;textBox1-&gt;Text;
  
                               String^ end_ = this-&gt;textBox2-&gt;Text;
  
                               //send data to setup timer on the microcontroller
                               this-&gt;serialPort1-&gt;WriteLine(sampling_period_);
                               this-&gt;serialPort1-&gt;WriteLine(days_);
                               this-&gt;serialPort1-&gt;WriteLine(hours_);
                               this-&gt;serialPort1-&gt;WriteLine(minutes_);
                               // send slave addresses
                               this-&gt;serialPort1-&gt;WriteLine(start_);
                               this-&gt;serialPort1-&gt;WriteLine(end_);
  
  
                               // receiving
                               int rec[100][8];
                               for (int i=0;i&lt;sizeof(rec[0]);i++){
                                   for (int j=0;j&lt;sizeof(rec);j++){
                                       rec[i][j]=int::Parse(this-&gt;serialPort1-&gt;ReadLine());
                                   }
                               }
                               myfile&lt;&lt;"ADC1"&lt;&lt;","&lt;&lt;"ADC2"&lt;&lt;","&lt;&lt;"ADC3"&lt;&lt;","&lt;&lt;"ADC4"&lt;&lt;","&lt;&lt;"ADC5"&lt;&lt;","&lt;&lt;"ADC6"&lt;&lt;","&lt;&lt;"ADC7"&lt;&lt;","&lt;&lt;"ADC8"&lt;&lt;endl;
                               for (int i=0;i&lt;sizeof(rec[0]);i++){
                                   for (int j=0;j&lt;sizeof(rec);j++){
                                       myfile&lt;&lt;rec[i][j]&lt;&lt;",";
                                   }
                                   myfile&lt;&lt;endl;
                               }
  
  
  
                           }
                           else{
                               this-&gt;textBox1-&gt;Text="Warning: port is busy or isn't open";
                               this-&gt;textBox2-&gt;Text="Warning: port is busy or isn't open";
                           }
                       }
                          catch(UnauthorizedAccessException^){
                              this-&gt;textBox1-&gt;Text="Unauthorized access";
                              this-&gt;textBox2-&gt;Text="Unauthorized access";
                          }
                       }
  
               }
      private: System::Void textBox1_TextChanged(System::Object^  sender, System::EventArgs^  e) {
               }
      private: System::Void label7_Click(System::Object^  sender, System::EventArgs^  e) {
               }
      private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
  
               }
      private: System::Void label8_Click(System::Object^  sender, System::EventArgs^  e) {
               }
      };
      }
  </code></pre>
  
  <p>I hope to get some help or at least any useful information in here.</p>
  
  <p>Thanks in advance.</p>