On 24 Sep 2007 at 22:01, sagar wrote:
Hi,
I have a C file(add.c) in which i have a function called add.now
i want to call the same add function from another file sub.c .Can any1
tell how to do that...
I would do this:
/* add.c */
add(a, b)
int a; int b;
If you would do this, you would never get a job as a C programmer in a
legitimate shop.
[snip]
I don't think anybody in this group will take someone seriously who
hasn't noticed that this style of function definition became obsolete
in C. EIGHTEEN YEARS AGO.
If you know better and you are trolling, just say so and I will plonk
you.
If you don't know better, buy a modern book on C, such as K&R 2 from
1989. Read and understand it before you post here again.
The situation is this: I am a hobbyist programmer and I've recently been
learning C from some old lecture notes. I've been told that some of the
syntax they use is now deprecated, but since all compilers will happily
compile the syntax I know, I don't really think there's any need to
start all over from the beginning. Especially as you can mix and match
old-style and new-style in the same program without any difficulty.
That is possible, but a very bad idea.
There is absolutely no question that adding prototypes to the language
is the single most significant improvement in the history of the C
language.
While there are still, perhaps, a few old UNIX kernels that can only
be compiled with antique, pre-ANSI compilers, it would be almost
impossible today to find a current compiler that could not accept at
least ANSI 1989/ISO 1990 C.
Writing new code using non-prototype function definitions is at best
foolish, at worst malicious. But submitting code samples to newbies
in this group using non-prototype function definitions, or
recommending that as a coding practice to newbies, is intolerable and
will only serve to get you pummeled repeatedly.
I also remember reading that this group caters for C according to any
standard version, including the "standard before the standard".
Yes, indeed, if someone has to deal with such code, for example to
update an ancient legacy application or deal with a very old third
party library. But I wouldn't say that this group supports anyone
writing per-standard C.
There are a number of more modern tutorials available online, some are
listed in the answer to question 18.9 of this newsgroup's FAQ (link in
my signature). Of these, Tom Torf's tutorial and Steve Summit's class
notes at eskimo.com are well regarded.
Come join us in the 21st century.
--
Jack Klein
Home:
http://JK-Technology.Com
FAQs for
comp.lang.c
http://c-faq.com/
comp.lang.c++
http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html