|
From: Ioannis V. <no...@ho...> - 2002-11-19 20:20:54
|
> -----Original Message-----
> From: dev...@li...
> [mailto:dev...@li...] On Behalf
> Of Paul Ardeleanu
> Sent: Tuesday, November 19, 2002 1:47 PM
> To: dev...@li...
> Subject: [Dev-C++] A simple problem
>
>
> Can Anyone tell me why this code WORKS FINE in DevC++?
> ANSI C says that it any Ansi compiler should give you an
> error (see K&R
> book).
> Thank you very much!
> Paul
>
> -----------------------------------------------------------
> main ()
> {
> printf("hello, world
> \n
>
>
> ");
> system("PAUSE");
> }
It is valid C90 code (and not C99).
The main() thing is implicit int. In C90 you could do:
const x=7;
and it was equivallent to const int x=7;
main() was equivallent to int main(). This is not the case in C99.
Now both in C90 and C99 if you do not declare a function and you use it,
a declaration of the type
int whatever_you_use(); is assumed. The empty parenthesis is not
equivallent to (void) as in C++. Empty parenthesis means that you want
to skip argument checking.
So when you use printf() without <stdio.h>, int printf(); is assumed.
Ioannis Vranos
* Programming pages: http://www.noicys.freeurl.com
* Alternative URL: http://run.to/noicys
|