Вы находитесь на странице: 1из 3

Lab 7: File IO

Project Goals

The goals of this project are to:


1. Get students familiar with File IO

Important Notes:

1. Formatting: Make sure that you follow the precise recommendations for the
output content and formatting: be sure to include command line arguments when you
start your program. Your assignment will be auto-graded and any change in formatting
will result in a loss in the grade.
2. Comments: Header comments are required on all files and recommended for the
rest of the program. Points will be deducted if no header comments are included.

Problem

Save your program as copy.c

Write a program which opens a input.txt file for reading and checks for a successful
connection to the file stream. If it cannot open the file, an error message should be displayed:
Cannot open input file. The input file is filled with an unknown number of integers,
each separated by a comma and a space. If the program can open the file, these integers should
be read in one by one and output to the screen, each written on a different line (just the integers -
disregard the punctuation and spacing).

In addition to the main functions, your program should have 1 more function:

displayValues()
Input Parameters: FILE pointer
Returned Output: none
Functionality: This function should accept a file pointer which has already been connected to a
file stream. It should read each of the numbers from the file, along with the comma and space
which separate the values. Each of the integer values should be displayed to the screen on a
separate line.

Run your program again, testing with mixed cases to see the different values.

Notes:
● You can use the feof() function to know when you’ve reached the end of the file!!!
Grading Rubric

Grading will be done for each problem as follows:

Algorithm Development 30%

Correctly-named file 5%

Header comment 5%

Program compiles 10%

Correctly declaring variables 10%

Correct File IO 25%

Correct loops 15%

Submission details
To submit your project, you will have to use the submission script. You do this by either:
1. Working on an ECC machine
2. Working on the provided VirtualBox installation

To Submit your project:


● Have a directory called “lab7”
● Save your *.c files in that directory
● To submit: (don’t type the ‘>’ symbols)
> cd lab7
> submit
The submission script copies all files in the current directory to our directory. You may submit as
many times as you like before the deadline, we only keep the last submission.

Academic Honesty
Academic dishonesty is against university as well as the system community standards. Academic
dishonesty includes, but is not limited to, the following:

Plagiarism: defined as submitting the language, ideas, thoughts or work of another as one's own;
or assisting in the act of plagiarism by allowing one's work to be used in this fashion.

Cheating: defined as (1) obtaining or providing unauthorized information during an examination


through verbal, visual or unauthorized use of books, notes, text and other materials; (2) obtaining
or providing information concerning all or part of an examination prior to that examination; (3)
taking an examination for another student, or arranging for another person to take an exam in
one's place; (4) altering or changing test answers after submittal for grading, grades after grades
have been awarded, or other academic records once these are official.

Cheating, plagiarism or otherwise obtaining grades under false pretenses constitute academic
dishonesty according to the code of this university. Academic dishonesty will not be tolerated
and
penalties can include cancelling a student’s enrolment without a grade, giving an F for the
course, or for the assignment. For more details, see the University of Nevada, Reno General
Catalog.

Вам также может понравиться