[Solved] c++ “Open with” [closed]


To start you off, try this foundation:

#include <string>
#include <iostream>
using std::string;
using std::cout;
using std::endl;
using std::cin;

int main(int argument_count,
         char * argument_list[])
{
  std::string filename;
  if (argument_count < 2)
  {
    filename = "You didn't supply a filename\n";
  }
  else
  {
    filename = argument_list[1];
  }
  cout << "You want to open " << filename << "\n";

  cout << "\nPaused, press Enter to continue.\n";
  cin.ignore(10000, '\n");
  return EXIT_SUCCESS;
}

This program will display it’s first parameter. So if you associate a file extension with this program, it should display the file name that you right clicked on (provided it has the correct extension).

I’ll let you build upon this for whatever application you are creating.

Note: the argument_list[1] refers to the text of the first parameter passed to the program. The name of the program is at argument_list[0].

solved c++ “Open with” [closed]