Forgive my question if it's easily answered, but last night I don't think I was quit getting it / figuring it out. Would there be a "good" way to pass 4 command line parameters to a program, then house this in a function so you can change them at will?
Here's an extremely hackish example as I couldn't figure much else out:
Code:
int ExtractZip( char * SourceFile, char * Destination, char * Name )
{
FILE * Tmp;
if( ( Tmp = fopen("Tmp.bat", "a") ) == 0 )
{
/* Nothing */
}
else
{
fprintf(Tmp, "@echo off\n");
fprintf(Tmp, "d:\\unzip.exe ");
fprintf(Tmp, "%s", SourceFile);
fprintf(Tmp, " -d ");
fprintf(Tmp, "%s >NUL", Destination);
printf("Copied: %s\n", Name);
}
fclose(Tmp);
system("tmp.bat");
remove("tmp.bat");
return 0;
}
System will obviously not work for this, if it did it would be fine as the intended platform has system, but, system can't accept changable arguments.
I looked into spawn, but couldn't figure much out.
Typical command line:
unzip.exe c:\path\to\file.zip FileIwant.ext -d c:\place\to\put\it
unzip.exe will remain the constant, the last 4 arguments however need to be changed at will....
Any suggestions?