Hi, I am new to C and so can not figure out the source of error I am getting. I have a program that calls a second program and passes an argument to it. When I try to assign the argument to a variable in the second program, I get a "Floating Error" error message. The program being called (named child, edited to remove peripheral stuff):
Code:
main(int argc, char *argv[])
{
pid_t pid; int ret_value, T, sleeptime;
T = atoi(argv[1]);
pid = getpid();
ret_value = (int) (pid %256);
srand(pid);
sleeptime = rand()%T;
sleep(sleeptime);
}
And the calling function:
Code:
int main(int argc, char *argv[])
{
pid_t pid, w; int k, status, T, N; char value[2];
// get command line arguments
T = atoi(argv[1]);
execl("child", "child", value, (char *) 0);
}
Any help you can give me would be very appreciated...thanks!