$24.99
CST8234 - C Programming
LAB 5
LAB OBJECTIVE
By completing this lab, you will learn to:
• Open files for reading and writing.
• Reading from a file.
• Writing to a file.
LAB INSTRUCTIONS:
STATEMENT OF THE PROBLEM:
In this lab we will look at very basic file IO operations. After completing
this lab, you should have a good idea on how to open files, either for
ready or writing, reading the content of a file, and writing content to
another file.
REQUIREMENTS:
You a given a simple text file, your goal is to read each string in that file
and write it another file.
The Following is a complete list of the program requirements:
1. Save the given text file, called FileRead.txt, in the same folder where
you code is going to be. This is important for the program to work.
2. In your C code, open FileRead.txt for reading only.
3. In your C code, open a second file, called FileOut.txt, for writing only
4. FileOut.txt shouldn’t exists in the folder. It will be created by the
program if the code is correct.
5. Check if the file open operation succeeded for both files, otherwise
print an error message and exit the program immediately.
6. If the files are open, read the content of FileRead.txt string by string
and write it to FileOut.txt after the sentence:
“I read from FileRead.txt ->”.
7. You will end up with more lines in the output file than there is in the
input one, since you are required to read only 1 string at the time.
8. When you submit your code, you also have to submit the input file
called FileRead.txt. Yet, DON’T submit the output file, to will be
created when the program runs.
The following is a sample of the output of the file.
SUBMISSION INSTRUCTIONS
• No late submissions are accepted.
• You MUST work in a group of maximum 2 students to complete this
lab. Individual work is NOT accepted.
• You must submit the source code for the program you wrote.
• Add all your files under a folder call “lastName-firstName-Lab5”, then
Zip the folder and submit the zipped folder only.
• Make sure to submit all files required to compile and run the program
on the instructor machine without any errors.
• DON’T submit any extra file. For example, the binary file (AKA object
or output) files like .exe or .o.
• Add a Readme.txt file that contain each student name and student
number.
• Brightspace is configured to keep the last submission only. Please
make sure your last submission in the one you want to get marked.
• All submission must be done on the main Brightspace shell,
19F_CST8234_010_ALL or 19F_CST8234_020_ALL, not the lab
section one.