using spawnl for a dos program
I've been working on this program in which I want to use spawnl to run another app. My question is how can I assign the spawned program to a variable? For example, I will read in the program to spawn in from a cfg file (text.)
void runProgram(char fileName[])
{
int flag;
flag = spawnl(P_WAIT, fileName, NULL);
if(flag == -1)
blah
The fileName is read in from the file and passed to runProgram after using strlen to make sure the name is valid. In the cfg file, the name appears as something like "C:\DOS\EDIT.COM"
I've also tried spawnlp but I am still unable to process the request. Do I need to allocate additional memory or include the environment? If so, how exactly do I do that? The error returned is always ENOENT. If I move EDIT.COM into the working directory and use spawnl(P_WAIT, "EDIT.COM", NULL) it works, but this isn't what my program needs. Can anyone help?
TIA