Write a C program, with documentation, that will: 1) Open the file myfile.txt (r
ID: 3534713 • Letter: W
Question
Write a C program, with documentation, that will:
1) Open the file myfile.txt (remember it is located in the root directory of the curren drive, which may no be in the c:drive)
2) If (the file did not open properly)
-display an error message
- drop to the bottom of the program and exit.
else
- use a while loop to input each string (line of text) in the file
- display each line as you input it
- close the file
3) Thank the user for using your program
You need to input the text line by line, not character by character.
You can detect the end of the sile using feof (file end of file). While you output three lines of text in the prior program, this program should correctly handle any number of lines including zeros.
One way to do this is to use a while loop that looks something like this pseudocode:
Read a line from the file and store it in mytext
While(not feof (in) // in is the name of the FILE variable
Display mytext
Read a line from the file and stor it in my text
End Loop
Explanation / Answer
Please rate with 5 stars :)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.