I am trying to run the following simple program which uses multithreading using pthreads. I compile it like: gcc -lpthread programName.c and it compiles fine. However, when I run it gives errors which I have pasted at the bottom of program.


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

void *thread_routine(void* arg)
{
printf("Inside newly created thread \n");
}

int main(int argc, char* argv[])
{
pthread_t thread_id;
void *thread_result;
pthread_create(&thread_id, NULL, thread_routine, NULL);
printf("Inside main thread \n");
pthread_join(thread_id, &thread_result);
}

-----------------------
Errors:
---------------------

/2.c: line 4: syntax error near unexpected token `('
./2.c: line 4: `void *thread_routine(void* arg)'



Any help will be appreciated!!