#include <pthread.h>
#include <stdio.h>
struct num
{
int thread_num;
int count;
};
void* char_print (void* number)
{
struct num* p = (struct num*) number;
int i = (p->count *(p->count + 1))/2;
printf("Now in thread %d: \n", p->thread_num);
printf("The sum is: %d\n", i);
//fputc (i, stderr);
return NULL;
}
int main ()
{
pthread_t thread1_id;
pthread_t thread2_id;
struct num thread1_args;
struct num thread2_args;
//thread1_args.count = 3;
printf("Enter the number: ");
scanf("%d" , &(thread1_args.count));
thread1_args.thread_num = 1;
pthread_create (&thread1_id, NULL, &char_print, &thread1_args);
pthread_join(thread1_id, NULL);
printf("Enter the number: ");
scanf("%d" , &(thread2_args.count));
thread2_args.thread_num = 2;
pthread_create (&thread2_id, NULL, &char_print, &thread2_args);
pthread_join(thread2_id, NULL);
return 0;
}