Re: Trouble with FILE
- From: Nate Eldredge <nate@xxxxxxxxxx>
- Date: Mon, 27 Oct 2008 12:20:26 -0700
Ruud <Ruud.Baltissen@xxxxxx> writes:
Hallo allemaal,
I created a program where I opened a file to read from. For various
reasons I had to split up this program in several modules. Variables
declared in one module are made accessible to other modules using an h-
file. The troubleshooter in this case are some file pointers to open
several files at the same time for reading or writing. I can declare,
let's say, an integer in a module as "int Counter;" and then as
"extern int Counter;" in the h-file. But for one or another reason
that doesn't work for "FILE *fp1;". The documentation I have has only
examples where FILE is only used in one module.
I don't quite understand your description. The usual approach is to have
extern FILE *fp1;
in a header (.h) file which is included into your source (.c) files, and
then
FILE *fp1;
in exactly one of your .c files. Also, make sure that <stdio.h> is
included in the header file, so that the FILE type is defined.
When you say "that doesn't work", what exactly do you mean? What
happens? If there's an error message, what exactly does it say?
By the way, you might find
http://www.catb.org/~esr/faqs/smart-questions.html
helpful in framing questions to get good answers.
.
- References:
- Trouble with FILE
- From: Ruud
- Trouble with FILE
- Prev by Date: Re: Trouble with FILE
- Next by Date: Re: Sequence Point before actual function call
- Previous by thread: Re: Trouble with FILE
- Next by thread: Re: Trouble with FILE
- Index(es):
Relevant Pages
|