Due: Friday, July 5th, 2024 by 10:00 am; No late exercises accepted.
Goals: Learn to use POSIX I/O routines
to scan a file directory and read the contents of
selected files.
(These routines will be needed in later parts of the large
project sequence. This exercise provides a chance to
learn how to use them in a much simpler setting
without additional complications of the larger project.)
Description: Write a C program that:
.txt (you should not scan
subdirectories, and you do not need to sort
the directory entries; you may also assume that no subdirectory
itself has a directory name ending in .txt)open / read / close functions,
copying the contents to stdout (you may use C standard library
functions (hint: fwrite) to write to stdout, but you must use
open / read / close
to read the files).stdout.
Copy the bytes from the input file(s) exactly as they are with
no changes.
As usual, your code must:
gcc -Wall -g -std=c17 -o ex7 ex7.c -- do not
submit a Makefile./li>
valgrind)ex7.c
that compiles with the command gcc -Wall -g -std=c17 -o ex7 ex7.c; do
not submit a Makefile.cpplint --clint.
readdir not being thread safe; you should use
readdir instead of readdir_r because
future updates to the Linux/POSIX standards are likely to
deprecate or remove readdir_r if that hasn't been
done already).You should submit your exercise to the course Gradescope.