No, actually , a is defined as char ... and comparing char with EOF ,, makes it go in infinte loop...as it never returns false.
correct me if i am wrong... On Fri, Jul 22, 2011 at 11:41 PM, aditi garg <[email protected]>wrote: > @shady. so in this case we shud use a!=-1 as the condition?? > > > On Fri, Jul 22, 2011 at 11:37 PM, shady <[email protected]> wrote: > >> you are scanning from stdin therefore it is not coming out of first for >> loop... because your terminating condition is for EOF, which is -1( scanf >> returns -1 ) at the end. >> >> >> On Fri, Jul 22, 2011 at 11:34 PM, shady <[email protected]> wrote: >> >>> well you didn't mention the question, directly posted the code with no >>> head-tail... wait will answer, it is not coming out of first loop >>> >>> >>> On Fri, Jul 22, 2011 at 11:26 PM, geek forgeek <[email protected]>wrote: >>> >>>> @shady this is nt a joke.. >>>> sorry if i am asking too stupid question >>>> i m getting an infinite loop here. >>>> not getting how? >>>> >>>> >>>> On Fri, Jul 22, 2011 at 10:40 AM, shady <[email protected]> wrote: >>>> >>>>> what kind of joke is this ? >>>>> >>>>> On Fri, Jul 22, 2011 at 11:02 PM, geek forgeek >>>>> <[email protected]>wrote: >>>>> >>>>>> #include<stdio.h> >>>>>> main() >>>>>> { >>>>>> FILE *fp; >>>>>> char a; >>>>>> fp=fopen("old.out","w"); >>>>>> if(fp==0) >>>>>> printf("File opening error"); >>>>>> else >>>>>> { >>>>>> for(scanf("%c",&a);a!=EOF;scanf("%c",&a)) >>>>>> fprintf(fp,"%c",a); >>>>>> fclose(fp); >>>>>> fp=fopen("old.out","r"); >>>>>> while(!feof(fp)) >>>>>> putchar(getc(fp)); >>>>>> } >>>>>> } >>>>>> >>>>>> -- >>>>>> You received this message because you are subscribed to the Google >>>>>> Groups "Algorithm Geeks" group. >>>>>> To post to this group, send email to [email protected]. >>>>>> To unsubscribe from this group, send email to >>>>>> [email protected]. >>>>>> 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 [email protected]. >>>>> To unsubscribe from this group, send email to >>>>> [email protected]. >>>>> 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 [email protected]. >>>> To unsubscribe from this group, send email to >>>> [email protected]. >>>> 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 [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > > > -- > Aditi Garg > Undergraduate Student > Electronics & Communication Divison > NETAJI SUBHAS INSTITUTE OF TECHNOLOGY > Sector 3, Dwarka > New Delhi > > 9718388816 > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Lalit Kishore Sharma, IIIT Allahabad, 7th Sem. Contact No. - +919670057056 , +918957935169 -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
