I got two int in main.c
, want to pass those two values to hello.c
to run it using exce()
, and return to main.c
to print it, how can I do that?
I try a lot of ways but it keep fail.
main.c
pid_t pid;
pid = fork();
int staff_id = 0210;
int staff_working_hours = 10;
if(0 == pid)
{
int args[] = {staff_id, staff_working_hours, NULL};
excev(" ./hello.c", args);
}
else
{
print(" "); //print here
}
return 0;
}
hello.c
int main()
{
//not want to print here, want to print by main.c
printf("Hello Staff ID: %d \n", staff_id);
printf("Your working hours is: %d \n", staff_working_hours);
return 0;
}