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.
