Why does one work and other does not....

An007kit's Avatar, Join Date: Oct 2007
Go4Expert Member
These are the two codes...
a)
Code:
#include<stdio.h>
int i=5;
void main()
{
int i=6;
printf("%d",i);
}
output = 6
b)
Code:
#include<stdio.h>
void main()
{
extern int i;
int i=6
printf("%d",i);
}
int i=5;
output=ERROR

Last edited by shabbir; 3Oct2007 at 04:10.. Reason: Code block
0
DaWei's Avatar, Join Date: Dec 2006
Team Leader
Read up on scope. Learn to put your code in code tags.