[Previous Homework] [Next Homework]

hw20 - File I/O 1


Read in a file, and display the contents on the console.

  • In an editor, create a text file that contains any text you wish. Save it in the same directory as your program.
  • Open the file in read mode.
    • Make sure that the file has been opened successfully.
  • Read the file, one line at a time, until it reaches the end of the file
  • After each line is read, write it out to the console.
  • Close the file.


From Linux on the GL machine:
  • Compile the program:
    gcc -o file1 file1.c

  • Run the program to make sure it works:
    ./file1

  • Use the SUBMIT utility turn in the homework.
    submit cs104_grasso hw20 file1.c file1


Reference Programs :



Make sure that you follow all the coding standards