Say I have the following code:
What I'm trying to do is be able to open the stream in fileOpener and then be able to make manipulations back up in main or pass the address of the pointer on to subsequent functions. When I try to compile the code I get a Segmentation Fault. Could someone help me out??? I'd greatly appreciate it.
Code:
#include<stdio.h>
#include<stdlib.h>
void fileOpener(FILE*);
int main(void)
{
FILE *fpFile;
char test[14];
fileOpener(fpFile);
fgets(test, sizeof(test), fpFile);
return(0);
}
void fileOpener(FILE *fpntr)
{
fpntr = fopen("inst.dat", "r");
}
Comment