My goal is to send an arbitrary text file to a exe which is a build of a c++ project. In the c++ project I would like to read the file which was sent to the exe. Hence, I think I need to pass the path of the sent file to the application (exe).
My c++ code [is working!]:
#include "stdafx.h"
#include <string.h>
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
std::string readLineFromInput;
ifstream readFile("input.txt"); // This is explizit.
// What I need is a dependency of passed path.
getline(readFile, readLineFromInput);
ofstream newFile;
newFile.open("output.txt");
newFile << readLineFromInput << "\n";
newFile.close();
readFile.close();
}
My Windows configuration:
In the following path I created a shortcut to the exe (build of c++ project): C:\Users{User}\AppData\Roaming\Microsoft\Windows\SendTo
Question:
I want to right click to an arbitrary text file and pass it (SendTo) to the exe. How can I pass the path of the sent file as an argument to the application such that the application can read the sent file?
When the path is passed as an argument the line of code should be like this, I guess:
ifstream readFile(argv[1]);
Much thanks!
David