2. the value of EOF is an integer which equals -1 (0xffffffff) and not 0xff becoz this is a valid Ascii character for this reason of tructation the while loop will always be true.....
On Thu, Jul 14, 2011 at 3:13 PM, Aniket Dutta <[email protected]>wrote: > 1. in ur program it will always output 1 because precedence of != is > greater than = (assignment) > > On Thu, Jul 14, 2011 at 2:57 PM, Aniket Dutta <[email protected]>wrote: > >> yeah i just figured it out >> >> >> On Thu, Jul 14, 2011 at 2:47 PM, rajeev bharshetty >> <[email protected]>wrote: >> >>> @Aniket Its getc itself !! >>> >>> On Thu, Jul 14, 2011 at 2:45 PM, Aniket Dutta >>> <[email protected]>wrote: >>> >>>> i think i should be like this >>>> while((c=fgetc(fp))!=EOF) and not getc >>>> >>>> >>>> On Thu, Jul 14, 2011 at 2:41 PM, rShetty <[email protected]> wrote: >>>> >>>>> // File Handling >>>>> #include<stdio.h> >>>>> #include<stdlib.h> >>>>> int main() >>>>> { >>>>> unsigned char ch; // I think there is problem somewhere in this >>>>> line ! Help !! >>>>> FILE *fp; >>>>> fp = fopen("abc","r"); >>>>> if(fp==NULL) >>>>> { >>>>> printf("Unable to Open"); >>>>> exit(1); >>>>> } >>>>> while((ch = getc(fp)!=EOF)) >>>>> printf("%c",ch); >>>>> fclose(fp); >>>>> printf("\n",ch); >>>>> return 0; >>>>> } >>>>> >>>>> abc contains some text such as "Kicit 44-1 Gokul;peth\0 nagpur" >>>>> >>>>> What should be the output of the program ?? >>>>> Explain the solution !! >>>>> >>>>> -- >>>>> 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. >>>> >>> >>> >>> >>> -- >>> Regards >>> Rajeev N B <http://www.opensourcemania.co.cc> >>> >>> -- >>> 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.
