#include<stdio.h> int main() { FILE *fp; unsigned char ch; /* file 'abc.c' contains "This is CuriousTab " */ 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; }
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.
Comments
There are no comments.Copyright ©CuriousTab. All rights reserved.