Re: [algogeeks] file handing

2010-06-13 Thread sharad kumar
for ques 2 Here the file *A.C* alone closed. To close all streams we have to use *fcloseall()* function -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from thi

Re: [algogeeks] file handing

2010-06-13 Thread jalaj jaiswal
declaration of fclose in stdio.h is as fclose (FILE*); so it has too many arguments... On Sun, Jun 13, 2010 at 9:06 PM, divya jain wrote: > sorry i pasted wrong questn unser 2.. > > the real question is > > which file will get closed through fclose() > #include > int main() > { > FILE *fp,*fs,*ft;

Re: [algogeeks] file handing

2010-06-13 Thread divya jain
sorry i pasted wrong questn unser 2.. the real question is which file will get closed through fclose() #include int main() { FILE *fp,*fs,*ft; fp=fopen("a.c","r"); fs=fopen("b.c","r"); ft=fopen("c.c","r"); fclose(fp,fs,ft); return 0; } 3. yes it is feof..srry typed it wrong... nd fgets(str,80,fp)

Re: [algogeeks] file handing

2010-06-13 Thread jalaj jaiswal
in question 1... ch gets the value of EOF... so first kicit 44-a gokulpeth\0 nagpur will get printed and then the value of EOF.. question number 2 .. seems to me as nrml ...i think myfile.c only gets closed in question number 3..it shld be fgets(str,79,fp) On Sun, Jun 13, 2010 at 2:49 PM, divya

Re: [algogeeks] file handing

2010-06-13 Thread BALARUKESH SIVARAMAN
For the 1st qn.. the o/p will print the code in the file and then print an infinite sequence of empty spaces. the reason is... In C EOF is defined to hold a value -1 which when assigned to unsigned becomes 255. So it goes in an unending loop even after encountering the end of file. In second qn..

[algogeeks] file handing

2010-06-13 Thread divya
1. wat ll be the o/p. plz explain y? // abc.c contains "kicit 44-a gokulpeth\0 nagpur" #include #include int main() { unsigned char ch; FILE *fp; fp=fopen("abc.c","r"); if(fp==NULL) { printf("unable to open the file \n"); exit(1); } while((ch=getc(fp))!=EOF) printf("%c",ch