Section 3, 4 and 5 from Reading and writing with files
File fread_fixed_integers.c
stored in the
sub-folder fread_fixed
in your shared folder.
Data files in binary format in the sub-folder
fread_fixed
in your shared folder.
Write a program in the file
fread_fixed_integers.c
stored in the directory
fread_fixed
in the shared folder, that implements
the following operations:
Check the program is started with a single argument. If that is not the case, print a message and terminate.
Open the file using as name the argument given to the program. If the operation fails, notify with a message and terminate the execution.
Read from the file a maximum of 10 integers and store them in an array of size 10. The program must execute with any number of integers stored (from 0 to 10). If the read operation fails, notify with a message. Otherwise, prints out the numbers on the screen.
Close the file and if the operation produces an error, notify it with a message on the screen.
Check the program with the
files fich_0_enteros
(empty file),
fich_07_enteros
(file with 7 integers) y
fich_10_enteros
(file with 10 integers) that you may
find in the shared folder.
Upload the program to the folder
fread_fixed
in your workspace in Subversion.