Home > Blockchain >  returning a file from a non main function to main and then pass it to other function in c
returning a file from a non main function to main and then pass it to other function in c

Time:11-13

thank you for taking your time to help me with my problem. The problem basically is that I am supposed to have two functions and a main function. The first function is supposed to open a file a second function is supposed to put them into two dynamic arrays.

I have found useful article on how to use a file as a parameter for other function but that solves only half of my problem. The thing I can not help myself with is actually opening it in a non-main function a returning it back to main and sending it to different non-main function.

CodePudding user response:

you need something like this

 FILE *openFile(){
    FILE * f = fopen("myfile","r");
    return f;
 }
  • Related