From: horst DOT kraemer AT snafu DOT de (Horst Kraemer) Newsgroups: comp.os.msdos.djgpp Subject: Re: A very basic question about C programming... diary of a newbie Part 1 Date: Fri, 14 Aug 1998 09:18:58 GMT Organization: [Posted via] Interactive Networx Lines: 67 Message-ID: <35d3ef05.75223464@news.snafu.de> References: <35D2A017 DOT 4808178C AT geocities DOT com> <35d30896 DOT 834512 AT news DOT Austria DOT EU DOT net> <35D3BC2B DOT 5F92B357 AT geocities DOT com> NNTP-Posting-Host: n163-169.berlin.snafu.de To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk On Fri, 14 Aug 1998 04:28:23 GMT, Merlin wrote: >Gerhard Gruber wrote: > >> Destination: Merlin >> From: Gruber Gerhard >> Group: comp.os.msdos.djgpp >> Date: Thu, 13 Aug 1998 08:16:15 GMT: >> >> >> No, this isn't a prototype. This is: >> >> >> >> void do_nothing(void); >> > >> > if you leave the void in brackets out it will be assumed.. >> >> That's wrong. >> >> The function(void) means that you specifically say that these function takes >> no arguments. a call like this function(i) yields an error. If you leave the >> void out then this means you don't give the compiler a hint what this function >> takes. writing function() or function(i) or function(a, b, c, d, e) is >> considered valid in this case, so leaving the void out is not the default vor >> void. It is totaly different. > >wow...i didn't know this...i was told it was assumed... You are referring to C++ then. C++ is not C. In C++ void f(void); and void f(); are both _prototypes_, and () is _identical_ to (void) in this case, i.e. void is _assumed_. In C void f(void); is a prototype and void f(); is a function declaration without a prototype. It means that the number of parameters f should get is known to the programmer. >but i still suppose that leaving void out would be ok... I mean it would be silly >to pass parameters to a function that didn't require any. So in effect it would >turn out pretty much the same whether or not you specify void in the brackets or >not... Of course it's ok - if you are a superman and never make unintentional mistakes. The purpose of prototypes is to allow the compiler to do error checking. Why would you intentionally refuse to accept this help if it is for free ? Humans may fail, and programmers are humans. Usually... Regards Horst