0

Hi guys, I have written a program that writes a .csv file readable in Microsoft excel. Is there a way I can launch the file with Microsoft excel once I compile and run the program?

#include <iostream>
#include <cstdlib>
#include <fstream>
#include <cmath>

using namespace std;

int main()
{
double T, a, b;

a=5.0;
b=2;

ofstream outputfile("Table.csv");
outputfile<<"a"<<","<<"T"<<endl;
            for(int n=0; n<10; n++){  
            double T, a, b;
            T=a+b;
            outputfile<<a<<","<<T<<endl;
            }

If I do this:

std::string excel_file = "Table.csv";
     outputfile.open(excel_file.c_str(), ios::in);
 
     if (outputfile.is_open()) {
cout<<"File opened"<<endl;
}
      else {
         cout << "Failed To Open File" << endl;
     }
outputfile.close();
system ("PAUSE");
return 0;

My file is written but does not launch.
Any help?

1
Contributor
1
Reply
2
Views
5 Years
Discussion Span
Last Post by Kristo.lane
0
// Can I use
outputfile.open ("Table.csv", fstream::in | fstream::out | fstream::app);
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.