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?

// Can I use
outputfile.open ("Table.csv", fstream::in | fstream::out | fstream::app);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.