Question: HW 6a -Read a toxt file 1.) Create a new C++ projest and name it as: Numbers 2) Create a text file and HW 6b

HW 6a -Read a toxt file 1.) Create a new C++ projest and name it as: Numbers 2) Create a text file and HW 6b - Read and write a text nte 1.) Include the following in the main.cpp file 2.) Add code so that the numbers that are read from the data.txt file are save it as: written to an output data.txt file named results.txt Create and save the file a C+ projoct - in the Resource folder 3.) After the numbers are written to the file, the followi ng message should be displayed: The data has been written to the tile Header Files Resource Files data.tt 4.) Open the results.txt file and verify that the file was written successfully. HW 6c Append data to existing data in a file. 1.) Include the following in the main.cpp file. 2.) Prompt the user to enter 3 more numbers, then read the numbers and write them source Files 3.) Enter the following numbers: 3 5 Nole: After you enter the 5, don t press the enter ke the results.txt file 4.) Save and close the file. 5.) Add another file and name it: main.cpp 6.) Write one statement that declares a file object and opens it for reading. 7) Include code that checks to see if the file opened successfully. - Include code so that when the data is written to file, it is appended (added on to the end of the existing data). 3.) Open the results.txt file and verify that the file was written successfully. OUTPUT - If the file does not open, the program should display: Error opening file! Here are the numbers in the file: o The program should then close. - Use a while loop to read the text file and output the numbers to the screen - The while loop should read the file until the end-of-file marker is encountered. - One number is read and displayed each iteration. OUTPUT See OUTPUT below) Enter 3 more numbers: 6 7 Here are the numbers in the file: The numbers have been written (appended) to results.txt. Press any key to continue . Press any key to continue
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
