<ne**********@yahoo.co.inwrote in message
news:5d**********************************@f47g2000 hsd.googlegroups.com...
i have a problem... have written two separate c files named read.c
and twinkle.c
the file read.c, after running stores some values in an array name
average[] and it has a count variable k......
now i need to read both average[] and the variable k from the
twinkle.c file
How do i integrate the two files r in short..how do i read the values
of average[] and count variable k from twinkle.c
Generally speaking, .H files allow you to declare an interface to the
corresponding .C file, which may include global variables.
When you start using .H files, there are a few things you want to provide
for:
a)A given include file should "stand alone", i.e. not require the inclusion
of any other files. (The generally requires that it itself include files,
and requires some mechanism that deals with multiple inclusion).
b)You want to avoid identifying the characteristics of anything in more than
one place (change and consistency risk).
c)You want full prototype linkage--you want the definition of a function
checked against the prototype, and the prototype checked against the
invocations.
Here are some sample files that may be a suitable example:
http://esrg.cvs.sourceforge.net/esrg....8&view=markup http://esrg.cvs.sourceforge.net/esrg...10&view=markup
Unfortunately the examples above don't have any global data, but it can be
placed in the .H file using the DECMOD_ ... construct.
For example:
DECMOD_MYMODULE int bart_simpsons_iq_readings[5]
#ifdef MODULE_MYMODULE
= {32, 49, 57, 23, 33}
#endif
;
Note that this expands a bit differently when compiling the owning module
rather than others.
Dave.