c - Cannot print characters from a file -


i trying read file character character , print on screen. however, character not displaying, getting box 0001 in it. code

#include <stdio.h> #include <stdlib.h> int main() {     file *fp;     int ch;      fp=fopen("myfile.txt", "rb");      while((ch = getc(fp)) !=eof){         putc(ch, stdout);     }      fclose(fp);      return 1; } 

you need check return values fopen, ensure opened file successfully, executing wrong directory. plus if file text file, should opening using "rt".


Comments

Popular posts from this blog

javascript - How to name a jQuery function to make a browser's back button work? -

python - Django-easy-pdf: xhtml2pdf reporting reportlab 2.2+ is required, but 3.0 installed -

collision detection - C++ library for mesh to mesh intersection: what is available? -