I'll admit that I feel like a bit of a dummy not knowing C syntax too well, and I'm writing code for an operating systems class. Syntax problems aren't what I should be getting stuck on, but I'm stuck right now. Here's code for one of our functions:
For reference sysargs is a structure that looks like:
void wait(sysargs *args)
int temp = 0;
int k_pid = 0;
k_pid = join(&temp);
args->arg1 = (void *)k_pid;
args->arg2 = (void *)temp;
if(k_pid == -2)
args->arg4 = (void *)-1;
args->arg4 = (void *)0;
printf("wait joined with %d\n", (int)args->arg1);
printf("wait staus was %d\n", (int)args->arg2);
At the print statements at the bottom, we get the correct output. However, when the function that called this one returns, and tries to use the values we stored in args, they're not the right values (i.e. instead of 5, we get 74600).
typedef struct sysargs
What are we doing wrong with how we store the values? Do we need to use memcpy, or are we casting incorrectly, or what?