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

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

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