I am trying this:
#include<stdio.h>
#include<pthread.h>
void * fun1(void *arg)
{
FILE *fp;
fp=fopen("data","w+");
if(fp==0)
{
perror("fopen");
return NULL;
}
perror("fopen");
fprintf(fp,"%s\n","file opened");
return NULL;
}
void main()
{
pthread_attr_t atr;
pthread_attr_init(&atr);
pthread_attr_setdetachstate(&atr,PTHREAD_CREATE_DETACHED);
pthread_t thread1;
pthread_create(&thread1,&atr,&fun1,NULL);
pthread_attr_destroy(&atr);
while(1);
}
i want to know if this thread will close the file pointer fp automatically or not after exiting.