Get Started
913

Q: Point out the error, if any, in the following program. #include "stdio.h" main() {       unsigned char;        FILE *fp;        fp = fopen ("trail", "r");        while (( ch = getc (fp)) ! = EOF)                printf ("%c", ch);        fclose (fp); }

  • उत्तर देखें
  • Workspace

Answer :
Explanation :

EOF has been defined as #define EOF -1 n the file "stdio.h" and an unsigned char ranges from 0 to 255 hence when EOF is read from the file it cannot be accommodated in ch. Solution is to declare ch as an int.

सबसे विस्तृत एग्जाम तैयारी प्लेटफार्म

Examsbook Prep ऐप आज ही प्राप्त करें