I'm trying to launch a particular txt file from my console app..
So far i have tried:
system("Notepad.exe", FULL_TXT_PATH);
But pre-compiler its telling me FULL_TXT_PATH is undefined but this is the variable that contains the full path and filename that is declared only a few lines above this and even in the same function..
I tried:
system("Notepad.exe FULL_TXT_PATH");
..which launches notepad but windows dialog says FULL_TXT_PATH.txt does not exist.
#include <string>
#include <cstdlib>
int main()
{
const std::string FULL_TXT_PATH = "place the path to the file to be opened here" ;
const std::string program = "C:\\windows\\system32\\notepad.exe" ; // favour using a fully qualified path
constchar quote = '\'' ; // required if the path contains space
const std::string command = program + ' ' + quote + FULL_TXT_PATH + quote ;
// drop elevated privileges if any
std::system( command.c_str() ) ;
}