I want to execute a C program from another C program. Actually I need to use system() function for my functionality as the control returns to the calling program. As I was not able to get the result with system(), I tried using execv() which was not successful either.
Below are the sample codes which I was trying
int main(void) {
puts("executing this prog from another prog"); 
return EXIT_SUCCESS; 
}
The above one is called test1.c
int main(void) {
execv("./test1",NULL); //system("./test1");
puts("!!!Hello World!!!"); 
return EXIT_SUCCESS; 
}
This is test2.c
With system(), I am getting the sh: 1: ./test1: not found error and with execv() its just ignoring the statement and printing the !!!Hello World!!!
Note : Mainly I want to know the functioning of system() for the problem I want to solve.
 
    