Re: Help wanted on some source codes
- From: "Old Wolf" <oldwolf@xxxxxxxxxxxxxx>
- Date: 29 Nov 2005 18:09:16 -0800
Becker wrote:
> 1.===========================================
> /* a.c */
> int x;
> int y;
>
> void main()
> {
> f();
> printf("%x %x\n", x, y);
> }
>
> /* b.c */
> double x;
>
> void f()
> {
> x = -0.0;
> }
All of your programs have undefined behaviour because there
are two variables called 'x' with external linkage.
Also, "%x" is only to be used for unsigned ints, and
main should return an int (allowing "void main" is compiler-
specific).
For an understanding of why GCC gives the results you see,
please ask your question on a GCC newsgroup.
.
- Follow-Ups:
- Re: Help wanted on some source codes
- From: slebetman@xxxxxxxxx
- Re: Help wanted on some source codes
- References:
- Help wanted on some source codes
- From: Becker
- Help wanted on some source codes
- Prev by Date: Re: Help wanted on some source codes
- Next by Date: Re: Help wanted on some source codes
- Previous by thread: Re: Help wanted on some source codes
- Next by thread: Re: Help wanted on some source codes
- Index(es):
Relevant Pages
|