I've never really used any of the exec() functions before, but I decided to try it out and found something strange.
The MSDN has the syntax of execl() like this:
However, if I want to use execl() I need to call it like this:
Why do I need to pass the name of the program that I'm executing twice when the syntax only lists it as the first parameter? If I run:
It will tell me that "Chris" is not a recognized command...
The MSDN has the syntax of execl() like this:
Code:
int _execl( const char *cmdname, const char *arg0, ... const char *argn, NULL );
Code:
int main()
{
string prog( "c:/temp/hello.bat" );
string arg1( "Chris" );
_execl( prog.c_str(), prog.c_str(), arg1.c_str(), NULL );
cout << "Should never reach here!" << endl;
return 0;
}
Code:
_execl( prog.c_str(), arg1.c_str(), NULL );