Answered step by step
Verified Expert Solution
Question
1 Approved Answer
a + Open for reading and appending ( writing at end of file ) . The file is created if it does not exist. The
a Open for reading and appending writing at end of file The file is created if it does not exist. The initial file position for reading is at the beginning of the file, but output is always appended to the end of the file.
The fopen function must:
instantiate a FILE object
initialize it according to the file modes
allocate a file stream buffer within the FILE object
open a file using the corresponding OS system call, eg open in Unix
Binary vs text files: Linux doesn't differentiate between text and binary files, so b type for fopen has no effect
Figure Differences between fileopening modes using stdio.h functions vs system calls.
Our stdio.cpp File
In addition to stdio.h you will also find stdiotemplate.cpp on Canvas to support with this program. The file stdiotemplate.cpp has already implemented: printf, setvbuf, setbuf, fopen, and feof.
Note that printf accepts only d and that the other functions are partially implemented just enough to be able to run the driver and performance test programs. No need to implement the rest of the function.
Also on canvas are the files driver.cpp and eval.cpp These should not be modified and are only used to test your implementation of stdio. They should include stdioh; they don't need to be aware of the existence of stdiocpp Note that stdiocpp is included at the bottom of stdioh so that it is possible to compile a user program like this:
g driver.cpp
g eval.cpp
Statement of Work
Step : Copy the source code and compile script from canvas to a Linux system.
Files: compile.sh eval.cpp driver.cpp stdio.h and stdiotemplate.cpp
Step : Rename stdiotemplate.cpp to stdio.cpp Implement all missing functions; noted bycomplete it in the file.
Step : Build the eval and driver executables using the compile.sh build script.
Step : Test your implementation of stdio.h using the driver executable and the texts provided on canvas: hamlet.txt othello.txt
Execute: driver hamlet.txt outputhamlet.txt
Compare outputhamlet.txt testtxt testtxt testtxt to versions on canvas
Execute: driver othello.txt outputothello.txt
Compare outputothello.txt testtxt testtxt testtxt to versions on canvas
Step : Test your implementation of stdio.h using the eval executable to test different readwrite combinations and sizes. The set of tests which should be run can be executed by running the evaltests.sh script.
Execute: evaltests.sh evaltestout.txt
The tests which are run are the following:
eval r u a hamlet.txt read hamlet.txt with unix IO at once.
eval r u b hamlet.txt read hamlet.txt with unix IO every bytes.
eval r u c hamlet.txt read hamlet.txt with unix IO one by one character.
eval r u r hamlet.txt read hamlet.txt with unix IO with random sizes.
eval r f a hamlet.txt read hamlet.txt with your stdio.cpp at once.
eval r f b hamlet.txt read hamlet.txt with your stdio.cpp every bytes.
eval r f c hamlet.txt read hamlet.txt with your stdio.cpp one by one character.
eval r f r hamlet.txt read hamlet.txt with your stdio.cpp with random sizes.
eval w u a test.txt write to test.txt with unix IO at once.
eval w u b test.txt write to test.txt with unix IO every bytes.
eval w u c test.txt write to test.txt with unix IO one by one character.
eval w u r test.txt write to test.txt with unix IO with random sizes.
eval w f a test.txt write to test.txt with your stdio.cpp at once.
eval w f b test.txt write to test.txt with your stdio.cpp every bytes.
eval w f c test.txt write to test.txt with your stdio.cpp one by one character.
eval w f r test.txt write to test.txt with your stdio.cpp with random sizes.
Step : Replace the first line of the eval.cppiestdioh with to use the Unixoriginal stdio.h rather than your own, recompile it with compilesh and rerun the evaltests.sh script.
Execute: evaltests.sh evaltestorgout.txt
What to Turn in
Criteria Grade
Code Source code that adheres good modularization, coding style, and an appropriate amount of comments. Use google coding guidelines: google.github.iostyleguidecppguidehtml
pts
Correctness
Execution output from some of the above tests possibly other nonpublished tests
Correct screenshots of the diff command in Step comparing your output files vs the originals
diff outputhamlet.txt Originalsoutputhamlet.txt
diff outputothello.txt Originalsoutputothello.txt
diff testtxt Originalstesttxt
diff testtxt Originalstesttxt
diff testtxt Originalstesttxt
Output files from running evaltests.sh with your and the original stdio implementations: evaltestout.txt evaltestorgout.txt
pts
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started