Mail Archives: djgpp/1999/02/25/00:46:58
At 12:42 PM 2/20/99 +0000, you wrote:
> It should work either way though, at least this code works just fine
>fore me:
>#include <iostream.h>
>
>main ()
>{
>cout<<"hey hey\n";
>}
foo.cc: 3: warning: return type of 'main' defaults to 'int'
foo.cc: 6: warning: return with no value in function not returning 'void'
(Strangely enough egcs fails to emit either of these with -Wall, but it
should and IIRC gcc 2.8.x does if you define a function like that... egcs
just silently outputs an 891 byte .o file as though that were a well-formed
program!)
>> #include <iostream.h>
>>
>> void main()
>> {
>> cout<<"Hello world"<endl;
>> return 0;
>> }
>
>I havn't done a whole bunch of progremming in C++ so I was wondering why you
>declared main as void and then have it return a value?
Because he made a mistake :-) It should return 'int'.
--
.*. "Clouds are not spheres, mountains are not cones, coastlines are not
-() < circles, and bark is not smooth, nor does lightning travel in a
`*' straight line." -------------------------------------------------
-- B. Mandelbrot |http://surf.to/pgd.net
_____________________ ____|________ Paul Derbyshire pderbysh AT usa DOT net
Programmer & Humanist|ICQ: 10423848|
- Raw text -