जॉइन Examsbook
1126 0

प्र: 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

उत्तर :
व्याख्या :

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.

क्या आपको यकीन है

  त्रुटि की रिपोर्ट करें

कृपया संदेश दर्ज करें
त्रुटि रिपोर्ट सफलतापूर्वक जमा हुई