Am noob, need assistance.
I am reading from a file into a char array and then trying to give that array to my custom function.
char *args[41];
FILE *f;
int hist = 0;
f = fopen("file.test", "a+");
while(fgets(*args, 40, f))
{ myFunction(hist, args);
hist++; }
Function:
void myFunction(int idx, char *args[])
{stuff}
The file exists and has several lines of text in it. fgets is seg faulting when I use the pointer array, however my function needs it that way for the rest of the program to work. The program works fine when not trying to read this file. Each line of the file should have no more than 40 characters. I believe fgets will read up to 40 characters and then also add a new line? I made the array size 41 just in case. Anyway, I also tried creating a normal char array but then myFunction won't accept it (and I can't easily change that function). What do?