Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Re: Why this Code Works ??

Thread Tools

Re: Why this Code Works ??

Chris Mears
Posts: n/a
      06-30-2003 Removed) (James) writes:

> int a ;
> int a ;
> main ( ) {
> a = 94 ;
> printf ("%d\n", a) ;
> }
> Why does this code compile without any warning.
> If u initialise a. It is an error ?. Why ?.

It works because there is no reason for it not to work. If you include
an initialiser with one of the declarations then that declaration
becomes a definition (rather than just a tentative definition). If you
try to initialise the object with both declarations you end up with two
definitions, which is illegal.

Chris Mears
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
why why why why why Mr. SweatyFinger ASP .Net 4 12-21-2006 01:15 PM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
vs2005 - Why all the errors? yet the code works. dbuchanan ASP .Net 9 02-08-2006 08:42 PM
When I turn on my PC, it works, works, works. Problem! Fogar Computer Information 1 01-17-2006 12:57 AM
After rebooting my PC works, works, works! Antivirus problem? Adriano Computer Information 1 12-15-2003 05:30 AM