Xref: news2.mv.net comp.os.msdos.djgpp:8613 Newsgroups: comp.os.msdos.djgpp From: design AT netcom DOT com (Chris Waters) Subject: old C vs. standard (was Re: Binary files and ^C chars-try again) Message-ID: Organization: Design and Delivery References: <3238BAD4 DOT A45980C AT alcyone DOT com> Date: Sat, 14 Sep 1996 10:16:49 GMT Lines: 56 Sender: design AT netcom19 DOT netcom DOT com To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp In article <3238BAD4 DOT A45980C AT alcyone DOT com>, Erik Max Francis wrote: >Samuel Vincent wrote: >> This is very old C.. I would recommend using ANSI C as follows: >> int main(int argc, char *argv[]) { >Presently, traditional-style function declarations are still supported in ANSI After a fashion--you may have unexpected conversions of char or short to int and float to double, however. And they are deprecated. And the standard is currently in review--this might disappear as soon as next year (though I grant it's unlikely). >> > FILE *fp,*fopen(); >> The fopen function is declared in stdio.h I believe. 1) You don't need to >> declare it further here. >Right. Technically (as long as we're being language lawyers), it is, in fact, illegal to declare it here. In fact, this may simply fail on Borland C for OS/2, where some standard library functions are declared with a "pascal" interface. Yes, Borland *is* allowed to do that by the standard. >> 2) You seem to have declared it incorrectly >> as taking no arguments... >In C++, yes; in C, no. Correct, but again, you may have unexpected difficulties with unintended promotions, as with old-style declarations. (I hate the term "traditional" in this context, as it sounds more legitimate than "old".) >> That exit() should really just be: return 0; >There's nothing wrong with using exit to terminate a program, even if you're >in main. But an integer function should return an integer. Therefore, you would have to use: #include /* or do I mean stddef.h? */ int main() { /* blah blah blah... */ exit (0); return 0; } Which is redundant and silly. :) Note also that exit(), technically, requires one of the standard headers to be included; return does not.