Velocity Reviews - Computer Hardware Reviews

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

Thread Tools

Re: Why this Code Works ??

John Tsiombikas (Nuclear / the Lab)
Posts: n/a
James wrote:
> 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 ?.
> regards,
> jame

It's perfectly legal, although kind of pointless to declare a twice...
If you declare and initialize a twice then it would be an error
(multiple definitions).
Also if I may suggest, declare main explicitly as int main(void) and
return 0; at the end.
I would also advise you to use proper indentations for clarity, and
don't forget to include <stdio.h> since you use printf

-- Nuclear / the Lab --

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