Well that's the thing -
Code:
result = execv("/Users/Scott/Desktop/hello.out", NULL);
printf("result = %i\n", result);
do{
printf("%c", prompt);
fgets(input, sizeof(input), stdin);
printf("%s", input);
}while(strcmp(input,"exit\n"));
printf("Exit, goodbye!\n");
return 0;
If execv is successful, you're running hello.out, and none of the red code runs.
If you're trying to create some kind of sub-process, then you use fork() as well, like
Code:
if ( fork() == 0 ) {
result = execv("/Users/Scott/Desktop/hello.out", NULL);
printf("result = %i\n", result); // only happens if execl fails
} else {
do{
printf("%c", prompt);
fgets(input, sizeof(input), stdin);
printf("%s", input);
}while(strcmp(input,"exit\n"));
printf("Exit, goodbye!\n");
return 0;
}