Question: 1. Write a section of code that attempts to open file foo.txt for input and, if the file does not exist, generates an error message

1. Write a section of code that attempts to open file foo.txt for input and, if the file does not exist, generates an error message and aborts the program 2. What could happen if you attempt to open a file for input and you do not check to see where or not the file exists. 3. Write a section of code that opens file diary.txt to add new data to the file without modifying the data that might already be in the file. 4. What could happen if you fail to close a file properly using the fclose() function. 5. Assume that the data file, data.txt, contains the data for a checking account. Each line in the data file contains a character for deposit or check cashed ('D' or 'C'), and a amount that is represented as a double. Write a section of code that opens the data.txt input file, reads the data on each line in the file, and outputs the data to the terminal window. 6. Repeat the following exercise but this time output each line of data to a new output file, checking.txt.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!