Click here to Skip to main content
15,923,142 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Is this possible? I would like to open an input file in one function, operate on the data in another and then pass it back.
Also, how do I set up a program to print the output to a printer?
Thanks. jimbob
Posted

C#
FILE *fhandle;
int my_function (FILE *my_file_handle){
   ...
}
fhandle = fopen (argv[1],"w");
my_function (fhandle);



see also http://www.linuxquestions.org[^]
 
Share this answer
 
v2
Comments
[no name] 2-Mar-11 15:24pm    
Good answer.
OriginalGriff 3-Mar-11 2:44am    
Short, sweet, and accurate - well done! 5!
Not only this is possible, but in many cases it is good to do so for software reuse and abstraction: you may need to abstract, for example, a set of write operations from file. In this way, you can use the same writing method on different files and combine different writing methods on the same file.

There is not need to "pass in back" though, because you really want to open and close file in the same function.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900