tag:blogger.com,1999:blog-959939550345671470.post7520423050502245729..comments2024-03-24T12:51:18.535+05:30Comments on C programming Interview questions and answers: extern keyword in cPriyanka kumarihttp://www.blogger.com/profile/08145649011863585828noreply@blogger.comBlogger53125tag:blogger.com,1999:blog-959939550345671470.post-66592443399949786322019-06-17T18:59:28.595+05:302019-06-17T18:59:28.595+05:30The examples are the real gems of this blog post.O...The examples are the real gems of this blog post.Other sites hardly showcase such nicely framed examples contrasted with different situations that a programmer might face><br />THANKS A LOT!!!!!cs_noobnoreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-8470384950029854662017-10-26T16:20:29.410+05:302017-10-26T16:20:29.410+05:30This comment has been removed by the author.Munihttps://www.blogger.com/profile/05703364708071057017noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-14583127493351426862016-05-08T02:16:18.673+05:302016-05-08T02:16:18.673+05:30I was wondering if you could tell me what this mea...I was wondering if you could tell me what this means as it is the name of a withdrawal from my bank account.<br /><br />OUTPUTON.C 39.95_VAnonymoushttps://www.blogger.com/profile/15795424031868935212noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-68836266410865873182016-03-07T23:22:41.565+05:302016-03-07T23:22:41.565+05:30If a variable is defined externally it is not exte...If a variable is defined externally it is not extern it is static by default please change it. Cause only static gives the output as zeroCoderhttps://www.blogger.com/profile/16341011027752341336noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-42151269498336870002016-02-20T15:39:28.557+05:302016-02-20T15:39:28.557+05:30thanz for the pleasant explanationthanz for the pleasant explanationjeniferhttps://www.blogger.com/profile/05086671193095375657noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-6712447780620259192016-02-05T17:34:25.587+05:302016-02-05T17:34:25.587+05:30Awesome boss Explanation was faduuuAwesome boss Explanation was faduuuRahulhttps://www.blogger.com/profile/03321032174277389899noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-22325768348097575042015-11-30T11:57:42.453+05:302015-11-30T11:57:42.453+05:30For better understanding of "extern" He...For better understanding of "extern" Here i and using a var1.c file as:<br /><br />var1.c:<br />#include"var2.c"<br />int main()<br />{<br /> printf("%d \n"sizeof(i));<br />}<br /><br />and file var2.c:<br /><br />#include<br />extern int i;<br />int abc()<br />{<br /> int j=0;<br /> printf("hello");<br />}<br /><br />o/p: 4<br /><br /><br /><br />var1.c:<Anonymoushttps://www.blogger.com/profile/02667474574327106887noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-48263593883608596282015-10-17T11:30:50.360+05:302015-10-17T11:30:50.360+05:30Best tut....Best tut....Piyushhttps://www.blogger.com/profile/18028240272139433762noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-39689741890380320542015-09-20T11:46:09.939+05:302015-09-20T11:46:09.939+05:30super helpful
super helpful<br />Anonymoushttps://www.blogger.com/profile/14992421972900303520noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-35920307563235414252015-07-24T12:48:19.122+05:302015-07-24T12:48:19.122+05:30every pointer can stores only address. so, general...every pointer can stores only address. so, generally address requires 2 bytes of memory space. it dos enot depends upon type(int or char or float) . But you are declaring far pointer (char far*s1).It has 4 bytes memory space. please check for thisAnonymoushttps://www.blogger.com/profile/14714346490714511167noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-31032942866627592462015-02-17T18:12:54.877+05:302015-02-17T18:12:54.877+05:30In one of the above example's above you have s...In one of the above example's above you have shown that if we write an extern variable which is from the different file it should be initialized otherwise it will through an error but why dint you initialize i and j in the example ? I did the same but it was giving error Anonymoushttps://www.blogger.com/profile/12816027229851279919noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-20798941109315041772014-06-24T00:01:47.194+05:302014-06-24T00:01:47.194+05:30#include
int main()
{char far*s1,*s2;
printf("...#include<br />int main()<br />{char far*s1,*s2;<br />printf("%d%d",sizeof(s1),sizeof(s2));<br />return 0;<br />}<br />for the above programme i got output as 4,2.can any one explain me how it possible?Anonymoushttps://www.blogger.com/profile/05971714243274192906noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-1887092630442633822014-06-07T16:49:38.669+05:302014-06-07T16:49:38.669+05:30Nice Explanation, But i'm having one doubt in ...Nice Explanation, But i'm having one doubt in <br /><br />#include <br />int main(){<br />extern int i; //It will search the any initialized<br /> //variable i which may be static or <br /> //extern.<br /> printf("%d",i);<br /> return 0;<br />}<br /><br />I'm getting this Err....<br /><br />"9 12 I:\Program\c\Array\rough.c [Error] static Anonymoushttps://www.blogger.com/profile/01345632453024050768noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-32838468237457255772014-05-25T13:32:31.732+05:302014-05-25T13:32:31.732+05:30I have a doubt regarding to conversion of int to
c...I have a doubt regarding to conversion of int to<br />char or vice-versa.<br />If we want to convert int to char then we use something like this.<br /><br />void main()<br />{<br /> int ch=65;<br /> printf("%c",ch);<br />}<br /><br />In memory 'ch' occupies 2 bytes.So,when its time to convert 'ch' into<br />char using %c it only use the lower byte,means the right Yogesh Gaikwadhttps://www.blogger.com/profile/13948808742167466123noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-74661080477636777902014-05-23T16:51:17.508+05:302014-05-23T16:51:17.508+05:30great tutorials....tnku bro....is there any tutori...great tutorials....tnku bro....is there any tutorial for "how to add functions in library" here.if yes pls show me??Yogesh Gaikwadhttps://www.blogger.com/profile/13948808742167466123noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-29193962911407547652014-04-10T12:27:56.312+05:302014-04-10T12:27:56.312+05:30It's very usefulIt's very usefulAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-3671522537290267632014-03-24T22:50:10.775+05:302014-03-24T22:50:10.775+05:30One Correction
Default storage class for global va...One Correction<br />Default storage class for global variable in staticAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-75156690403184716562014-02-22T08:26:39.082+05:302014-02-22T08:26:39.082+05:30Thanks a lot :)Thanks a lot :)Anonymoushttps://www.blogger.com/profile/13800916614873018650noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-41859150978165342242014-02-10T13:15:25.273+05:302014-02-10T13:15:25.273+05:30Is there any difference between following declarat...Is there any difference between following declarations?<br />1 : extern int fun();<br />2 : int fun();<br /><br /><br />A. Both are identical<br />B. No difference, except extern int fun(); is probably in another file<br />C. int fun(); is overrided with extern int fun();Anonymoushttps://www.blogger.com/profile/10656721715422359993noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-77656046302492405312013-12-31T16:32:28.136+05:302013-12-31T16:32:28.136+05:30sema........sema........Unknownhttps://www.blogger.com/profile/15208816021085405382noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-42269639869235521332013-12-13T21:52:06.629+05:302013-12-13T21:52:06.629+05:30nice explanation....thank you....
nice explanation....thank you....<br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-44119537757936816552013-10-01T17:58:22.877+05:302013-10-01T17:58:22.877+05:30Basically, extern keyword is a default storage cla...Basically, extern keyword is a default storage class. If you do not declare the keyword globally then it will take as zero or null but if you declare extern keyword globally then you need to initialize it . Now locally, if you do not declare extern keyword then the compiler will take it as a default storage class viz auto. Auto is a default storage class. So it is necessary to declare extern Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-12542085238205735022013-09-30T18:07:51.228+05:302013-09-30T18:07:51.228+05:30hi I WANT A PROGRAM ....ON STORAGE CLASSES.....QUE...hi I WANT A PROGRAM ....ON STORAGE CLASSES.....QUESTION IS WRITE AC PROGRAM TO ILLUSTRATE AUTO,REGISTER,STATIC,EXTERN.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-6283834119087968142013-09-18T21:26:41.578+05:302013-09-18T21:26:41.578+05:30in 3rd point it says the extern keyword looks for ...in 3rd point it says the extern keyword looks for the intialization globally... and multiple declarations cannot be accepted bt in the 8b y local variable is given as output either it throw compilation error for multiple declarations or it should take the value of 10 , please clarify the doubt <br />#include <br />extern int i;<br />int main(){<br /> i=25; //Assignment statement<br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-24148918864364776652013-09-10T16:05:03.963+05:302013-09-10T16:05:03.963+05:30hi good question
I think that as extern keyword o...hi good question <br />I think that as extern keyword only declare the variable ,no memory is allocated to it.Memory is allocated when you initilise it this can be done through int i;or int i=any_value;<br />In first case you didn't initialise but assignment is done.<br />While in second by writing int i; in last you initialise it .<br />This is according to how compiler work whenever it seesAnonymousnoreply@blogger.com