10 Program to Demonstrate EXECVE System Call in C

Program Main.c:

#include <stddef.h>
#include <unistd.h>

void main()
{
    char* arg_list[] = { "myprog", "ARG1", "ARG2", NULL };

    execv( "call", arg_list );
}

Program Call.c:

#include<stdio.h>

void main(int argc,char **argv)
{   
    printf("\nArgc: %d",argc);

    for(int i=1;i<argc;i++)
    {
        printf("\n %s",argv[i]);
    }
}

Output:



Previous
Next Post »