Reply embedded.. 

-----Original Message-----
From: Madhukar mythri [mailto:[EMAIL PROTECTED] 
Sent: Sunday, December 26, 2004 10:58 PM
To: Thirumoorthy Chettiannan; Nitin Dubey; Pradyut Bhattacharya
Cc: [EMAIL PROTECTED]
Subject: (PT) Re: Diff b/w global & external variable's??



>yeah u r correct only as per books....
>but, comming to praticle...
> how ever we have to include the file know....
> if we don't declare as extern type also we can access  the variable in
other files....
 
>So, please tell me any praticle difference where extern type declaration is
compulsory....

If you declare a variable in  A.c file, and in B.c file (which is going to
be part of the executable), you try to access that variable, your attempt
will fail (compiler will give an error) unless you declare that variable as
extern in B.c. Of course if you include the declaration in A.H and include
A.h in both A.c and B.c you will succeed. So, extern type is mandatory where
you are using a variable which is declared in a different scope. If you just
declare a variable as extern but don't have the actual definition in one of
the files in the excutable, the linker will throw an error.


--- Thirumoorthy Chettiannan
<[EMAIL PROTECTED]> wrote: 
> Hi Madhu Kumar,
>    Global Variables scope is limited to the file in which the variable 
> resides. But EXTERN variable can be accessed globally in all the 
> files.
> 
> Examples.
>   A global Variable A residing on file exp1.c can't be accessed from 
> exp2.c.
>   A EXTERN variable B residing on the file exp1.c can be accessed from 
> exp2.c.
> 
>   Hope this clears you doubt.
> 
> --
> With Warm Regards,
> Thirumoorthy.C,
> Ready Test Go Pvt Ltd,
> No 22, Oliver Road,
> Mylapore,
> Chennai - 4.
> Office : +(91)44 55546600 Extn 219
> Mobile: +(91) 98407 32016
>  

________________________________________________________________________
Yahoo! India Matrimony: Find your life partner online
Go to: http://yahoo.shaadi.com/india-matrimony






To unsubscribe : [EMAIL PROTECTED]

 
Yahoo! Groups Links



 






------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/EbFolB/TM
--------------------------------------------------------------------~-> 

To unsubscribe : [EMAIL PROTECTED]

 
Yahoo! Groups Links

<*> To reply to this message, go to:
    
http://groups.yahoo.com/group/Programmers-Town/post?act=reply&messageNum=4836
    Please do not reply to this message via email. More information here:
    http://help.yahoo.com/help/us/groups/messages/messages-23.html

<*> To visit your group on the web, go to:  
    http://groups.yahoo.com/group/Programmers-Town/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to