Mar 14, 2015 at 7:39pm UTC
I want to use _IO_FILE and initialize it by a file path.
I defined f:
_IO_FILE f;
but I cannot init it by a file name and then pass it to Func1 which is defined as follows:
int Class1 :: Func1 (List& _list, FILE& _file)
I tried by using fopen(filename,"r"); but it does not work.
Last edited on Mar 14, 2015 at 7:43pm UTC
Mar 14, 2015 at 7:46pm UTC
Last edited on Mar 14, 2015 at 7:47pm UTC
Mar 14, 2015 at 7:49pm UTC
I cannot change the func1, so I need the type of __IO_FILE aka FILE.
Mar 14, 2015 at 8:06pm UTC
int Class1 :: Func1 (List& _list, FILE& _file)
"_file" is a pointer. You cant send it in via reference. Change it to
int Class1 :: Func1 (List& _list, FILE* _file)
Mar 14, 2015 at 8:08pm UTC
I should not change the FILE& to FILE*.
Last edited on Mar 14, 2015 at 8:12pm UTC
Mar 14, 2015 at 8:17pm UTC
Is there any solution that I can define different way f and then pass it to the func1 (by FILE&)?
Last edited on Mar 14, 2015 at 8:18pm UTC
Mar 14, 2015 at 8:22pm UTC
I mean... It looks like you're using classes, which means you're coding in c++ but still you're using C-style file-handling which makes no sense to me. I know that in c++ style file handling you can send in by reference, but in C Im honestly not sure, hopefully someone with that knowledge can come and answer your question.
Why are you using c-style file handling?
Mar 15, 2015 at 2:12am UTC
I need to add new codes to provided function. Is anyone has a suggestion?
Last edited on Mar 15, 2015 at 2:13am UTC