#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

typedef struct {
int a;
int b;
} TWONUMS;

void  *addnums(void *nums)
{
   TWONUMS *temp = (TWONUMS *)nums;
   printf("Thread: Sum of numbers = %d\n", temp->a + temp->b);
   temp->a = 6;
   temp->b = 6;
   pthread_exit(NULL);
}

int main()
{
   pthread_t thread;
   int rc;
   TWONUMS two;
   
   two.a = 4;
   two.b = 5;
   rc = pthread_create(&thread, NULL, addnums, (void *)&two);
   if (rc){
      printf("ERROR; return code from pthread_create() is %d\n", rc);
      exit(-1);
   }
   pthread_join(thread, NULL);
   printf("Parent: Sum of numbers = %d\n", two.a + two.b);
   pthread_exit(NULL);
}
