I need to reassign a single file pointer to multiple files sequentially.
I have the file paths correctly in a string path.
when i pass the path and the file pointer to a function to reassign, I get "Aborted (core dumped)"..
FILE * fptr; //Global file pointer
FILE * getfptrr(char * path)
{
fclose(fptr);
fptr = fopen(path, "r");
if(fptr!=NULL)
return fptr;
else
{
printf("\n Something's Wrong!!! \n");
exit(1);
}
}
Should I use frepoen?? and how...
Or any other options??