@sanju, if u declare a variable with extern, at compile time its defn is nt looked for, rather @ link time corresponding defn is looked for by the linker. nd if the defn is nt ther, it will raise a linker error, as in case of this prog
@rahul, ya off course, for a variable to be global it hs to be defined at file scope. On Wed, Aug 31, 2011 at 11:29 AM, Sanjay Rajpal <srn...@gmail.com> wrote: > Linker error, failed to find symbol 'var'. > > > Sanju > :) > > > > On Wed, Aug 31, 2011 at 8:25 AM, rahul sharma <rahul23111...@gmail.com>wrote: > >> but it is defined inside main????u mean to say for varibale to be gloabal >> it must be defines outsyd all fxns?? >> >> >> On Wed, Aug 31, 2011 at 8:35 PM, Ashima . <ashima.b...@gmail.com> wrote: >> >>> u hv just declared the variable and not defined it.So no memory is >>> allocated to var. so u l get the undefined reference error. >>> either remove extern or define new local variable int var =10; >>> Ashima >>> M.Sc.(Tech)Information Systems >>> 4th year >>> BITS Pilani >>> Rajasthan >>> >>> >>> >>> >>> On Wed, Aug 31, 2011 at 7:56 AM, Rajesh Kumar >>> <testalgori...@gmail.com>wrote: >>> >>>> What we do to remove error?? >>>> #include<stdio.h> >>>> extern int var; >>>> main() >>>> { >>>> var=10; >>>> return 0; >>>> } >>>> >>>> Regards >>>> Rajesh Kumar >>>> >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Algorithm Geeks" group. >>>> To post to this group, send email to algogeeks@googlegroups.com. >>>> To unsubscribe from this group, send email to >>>> algogeeks+unsubscr...@googlegroups.com. >>>> For more options, visit this group at >>>> http://groups.google.com/group/algogeeks?hl=en. >>>> >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Algorithm Geeks" group. >>> To post to this group, send email to algogeeks@googlegroups.com. >>> To unsubscribe from this group, send email to >>> algogeeks+unsubscr...@googlegroups.com. >>> For more options, visit this group at >>> http://groups.google.com/group/algogeeks?hl=en. >>> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to algogeeks@googlegroups.com. >> To unsubscribe from this group, send email to >> algogeeks+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.