Warning: implode(): Invalid arguments passed in /www/wwwroot/jobquiz.info/mdiscuss.php on line 336 What will be the output of the program ? #include<stdio.h> int main() { FILE fp; unsigned char ch; / file 'abc.c' contains "This is IndiaBIX " / fp=fopen("abc.c", "r"); if(fp == NULL) { printf("Unable to open file"); exit(1); } while((ch=getc(f ?->(Show Answer!)
1. What will be the output of the program ? #include<stdio.h> int main() { FILE fp; unsigned char ch; / file 'abc.c' contains "This is IndiaBIX " / fp=fopen("abc.c", "r"); if(fp == NULL) { printf("Unable to open file"); exit(1); } while((ch=getc(fp)) != EOF) printf("%c", ch); fclose(fp); printf("\n", ch); return 0; }
Ask Your Doubts Here
Comments
By: guest on 01 Jun 2017 06.01 pm
The macro EOF means -1. while((ch=getc(fp)) != EOF) Here getc function read the character and convert it to an integer value and store it in the variable ch, but it is declared as an unsigned char. So the while loop runs infinitely.