Question: need help in c++ language..MA Be careful about using scanf and whitespace. We explicitly use a colon as a separator after numeric values instead of
need help in c++ language..MA
Be careful about using scanf and whitespace. We explicitly use a colon as a separator after numeric values instead of whitespace. Why? Imagine if the file contents started with a series of spaces; scanf would consume these after reaching the file size, and then we would end up not reading the file from the beginning. Not good! What if your file path has a space in it and you're using scanf? It will stop early and not return the full path. For this reason, you must use another function like fread, to read the specific number of bytes for the file path and file data. You will need to use a buffer and a loop to copy file contents data in and out of the archive.
You can find examples of archive files in this format in the /scratch/archive_examples directory on os1.
Suggested Documentation
- Man pages:
(0p) for overview of file properties. - stat(2) for file size, type, etc.
for I/O. - fread/fwrite/fopen/fclose(3) etc. in the stdio library.
(0P) for reading directory entries. (0P) for a list of new data types. - getcwd(3) for saving the current directory before recursing.
- chdir(2) for changing the current directory before and after recursing.
Skeleton code
This skeleton code is provided to help you get started. You may use any parts of it without citation in your submission.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
