Opening a created document using c++ and visual studio 2008

So I've wrote a program that asks the user for a file output("test.txt, etc.) and then the program writes to that document. What I would like to do is, after the program has finished writing to the document, I want to open that document using c++. I've been looking around for it and have figured out how to open a program like mspaint, but I want to be able to open the document I write to. Any helped is appreciated.

JP
http://cplusplus.com/doc/tutorial/files/

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// reading a text file
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

int main () {
  string line;
  ifstream myfile ("example.txt");

  if (myfile.is_open())
  {
    while (! myfile.eof() )
    {
      getline (myfile,line);
      cout << line << endl;
    }
    myfile.close();
  }

  else cout << "Unable to open file"; 

  return 0;
}

Okay so this just shows what it printed to the document on my c++ executable. I want it to actually open, lets say it's a .txt file, the notepad file I just wrote to, so it will open the notepad program and display what I just wrote to the file. Or, .xls - excel, or .docx - msword.
if you just want to open call "shellexecute"
Care to explain how shellexecute can be implemented in visual studio? Thanks for the input
Topic archived. No new replies allowed.