hi guys
i have only basic knowledge of c so guys plz help me .....
i want 2 call c executable which requires file name as argument and i need to modify file contents before calling that executable now my question is how can i call this c executable inside another c program with arguments ??
i need this coz i can only call c program from cobol program and that c program should call this executable which requires file as argument in which i have to store my data and this data changes every time i call this c ....
Are you expecting to use the output of the executable file in the C program that calls it? If you do, then you'll need to use popen (read the man page for how to work with it). If not, then just use the exec family of functions (again the man page will tell you how to use them).
HI,
If you want to continue the execution of C prgram even after calling the executable from the C program, then try to use system() function call.
You can create a string with executable name and the arguments printed to the string using sprintf().
Then pass the string as argument to system() call.
If needed i can give you a example.
Raghu
#include<unistd.h>
int main()
{
const char* command ="./freenull";
execvp(command,NULL);
return 0;
}
/* in the same programme if u want u can create a child and can do the same inside that*/
You mean: system (command);
You probably want to return EXIT_SUCCESS (#include <stdlib.h>), not 1. The normal exit status for successful programs in unix is 0. Non-zero values are usually used to indicate some kind of failure.