You need pointer to array of FILE* type , do as I did in the bottom function. Also add () parentheses, such as (*in) , to overwrite priority . By default, [] takes precedence over the * operator. SEE: Operator Priority
void openfiles (FILE* (*in)[2], FILE **out){ (*in)[0] = fopen("in0", "r"); (*in)[1] = fopen("in1", "r"); *out = fopen("out", "w"); }
My example above a line can be useful for understanding the concept:
#include<stdio.h> void f(char* (*s)[2]){ printf("%s %s\n", (*s)[0],(*s)[1]); } int main(){ char* s[2]; s[0] = "g"; s[1] = "ab"; f(&s); return 1; }
output:
g ab
Codepad
For OP : also read Lundin's comments on my answer. Get out of the help!
source share