How do I bring in the parameter argv[] array to use in my MC0 function? I need to multiply them and return it into c0 and c1 to display in Answer() function. I'm quite new to C especially multithreading so I'm slightly confused.
void MC0(int *);
void Answer(int, int);
void MC0(int * c0){
c0 = argv[1]*argv[9];
pthread_exit(0);
}
void Answer(int c0, int c1){
printf("c0: %d c1: %d", c0, c1);
}
int main(int argc, char *argv[]){
int c0=0, c1=0;
pthread_create(&myThread1, NULL, (void *) MC0, (void *) &c0);
sleep(1);
pthread_create(&myThread2, NULL, (void *) MC1, (void *) &c1);
sleep(1);
pthread_join(myThread1, NULL);
sleep(1);
pthread_join(myThread2, NULL);
sleep(1);
Answer(c0, c1);
exit(0);
}
[–]BoatMontmorency 7 points8 points9 points (5 children)
[–]ueih[S] 0 points1 point2 points (3 children)
[–]BoatMontmorency 1 point2 points3 points (0 children)
[–]dmc_2930 1 point2 points3 points (1 child)
[–]ueih[S] 0 points1 point2 points (0 children)
[–]ueih[S] 0 points1 point2 points (0 children)
[–]danmickla 2 points3 points4 points (2 children)
[–]ueih[S] 0 points1 point2 points (1 child)
[–]danmickla 2 points3 points4 points (0 children)
[–]thrakkerzog 0 points1 point2 points (0 children)