[NTLUG:Discuss] OT: C question
David Stanaway
david at stanaway.net
Wed May 10 21:01:56 CDT 2006
I have seen this problem when main is declared as returning void and you
try to return an integer.
This doesn't seem to cause any problem with gcc-3.3 or gcc-4.0 on
intel/linux for me, but with earlier versions of gcc I am pretty sure I
have seen that, maybe on sparc/solaris.
Stuart Yarus wrote:
> Hi,
>
> Just checking... have you included the stdlib.h header?
>
> Stuart
>
>
>
> Fred James wrote:
>> All
>> I have a C program that if compiled with a "return (0);" as the last
>> line in main(), runs correctly but give a "Bus error(core dump)" message.
>> If I compile the same C program with a "exit (0);" as the last line in
>> main(), the run is also correct, and there is no error message.
>>
>> What is the difference, please?
>>
>> K&R says: "Within main, return expr is equivalent to exit(expr). (page
>> 164, paragraph 2, "The C Programming Language - Second Edition" by Brian
>> W. Kernighan, Dennis M. Ritchie, Prentice Hall Software Series,
>> Copyright 1988, 1978, by Bell Telephone Laboratories, Incorporated).
>>
>> The platform is SGI IRIX 6.4
>>
>> Thank you in advance for any help you may be able to offer
>> Regards
>> Fred James
>>
>> _______________________________________________
>> http://ntlug.pmichaud.com/mailman/listinfo/discuss
>>
>
>
>
>
> _______________________________________________
> http://ntlug.pmichaud.com/mailman/listinfo/discuss
>
More information about the Discuss
mailing list