Write two statements that use a file stream object named pets to open a file named pets.dat. (Show how to open the file with a member function and at the definition of the file stream object.) The file should be opened for input.
Want to see the full answer?
Check out a sample textbook solutionChapter 12 Solutions
Starting Out With C++ From Control Structures Through Objects, Student Value Edition (8th Edition)
Additional Engineering Textbook Solutions
Digital Fundamentals (11th Edition)
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
Starting Out with Programming Logic and Design (4th Edition)
Database Concepts (8th Edition)
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
- Question 2: Write a program that reads words from a text file and displays all the words (duplicates allowed)in descending alphabetical order. The words must start with a letter. The text file is passed as acommand-line argument.arrow_forwardWrite a function, WriteFile(), that saves information to a text file. The function receives a string value (obtained from Question 3.2) that is written to the text file. The function does not return any value to the calling statement.Store the output text file as Output.txt.The output must be added on a new line to the text file each time without erasing any existing The above functions (ReadFile(), Decode(), and WriteFile()) must now be implemented in the main program in the following order:1. Create a list of type character, i.e. the data type that is stored in the list is text.2. Read the contents of the file to the lists with ReadFile(). Display the number of lines that are read from the text file.3. Decode each card number with the Decode() function by passing the list to the function.4. As each card number is decoded, write the information to an output file with WriteFile(). The WriteFile() function should be called from within the Decode() function.arrow_forwardWrite data to a text file file with class Formatter. Ask the user to enter an account number, first name, last name, and account balance. Make sure to provide the user with an end-of-file indicator to end input. (Using Java)arrow_forward
- (C#)Assume inputFile references a StreamReader object that is associated with a file that is already open. Which statement can read all the items in the file without knowing how many items the file contains? Question 9 options: while (!inputFile.EndOfStream) { } while (inputFile.EndOfStream) { } while (inputFile != EndOFStream) { } while (inputFile == EndOfStream) { }arrow_forwardWrite code that opens an output file with the filename number_list.txt, but does not erase the file’s contents if it already exists.arrow_forwardAssuming that a text file named FIRST.TXT contains some text written into it, write a function namedcopyupper(), that reads the file FIRST.TXT and creates a new file named SECOND.TXT contains allwords from the file FIRST.TXT in uppercase. (write c++ code)arrow_forward
- Write data to a text file file with class Formatter. Ask the user to enter an account number, first name, last name, and account balance. Make sure to provide the user with an end-of-file indicator to end input. (Java)arrow_forwardDescribe the difference between reading a file with the >> operator and thegetline function.arrow_forwardQ2: Suppose that the file (employee.txt) shown in the figure was stored in the default path, the data stored in this file is employee's name (string), his age (integer), and his salary (double); this data is stored for unknown number of employee. Write a program that uses a function which receives a file stream object of the file (employee.txt) and then it creates another file to store the names of the employees whose ages are over 30 years. T employee.txt - Notepad ~ — o File Edit Format View Help Ahmed 33 Ali 37 hasan 4 mohammed kamal 55 bassam 25 hussam 22 1.5e+06 1.6e+06 1.7e+06 43 1.8e+06 1.9e+06 900000 800000 100% Windows (CRLF) UTF-8arrow_forward
- 3. Write a function which reads an already existing file “File1.txt” and write digits (0-9) in to a new text file “mynumber.txt” and non digits into a file “Text.txt”.in c++arrow_forwardWrite a function named file_sum that takes as a parameter the name of a text file that contains a list of numbers, one to a line, like this: 23.77 116 94 -12.8 0 14.999 The function should sum the values in the file and write the sum (just that number) to a text file named sum.txt.arrow_forwardWrite a function to output patient information that are stored in a file. One of the parameters of the function must be no. of patients to output and another one the name of the file where the patients’ information is stored.arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage