STARTING OUT WITH C++ MPL
9th Edition
ISBN: 9780136673989
Author: GADDIS
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 13.1, Problem 13.11CP
Show how to use the constructor of the fstream class to open a file for input without having to call the open function.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a C++ Program that reads a file named "Paragraph.txt" as input to the Program. Your task is to read
the file in such way that it read a single word from file and stores in Array after memory allocation. After
that when it reads new (Next) word from file append it to the array. (Need to regrow the array)
At the end of this and other textbooks, there usually is an index that lists the pages where a certain word appears. In this problem, you will create an index for a text but, instead of page number, you will use the line numbers.
You will implement function index() that takes as input the name of a text file and a list of words. For every word in the list, your function will find the lines in the text file where the word occurs and print the corresponding line numbers (where the numbering starts at 1). You should open and read the file only once
Create the python function as part of a python program. The data required for the function should be created in the python program and passed to the function.
its an exercise pyrthon problem 6.27
Write a C++ program using classes that readslines from a file until the end of file. The program should prompt the user for the file name to read from. The program should open the file for reading, and if the filecannot be opened, print the message “File couldn’t be opened”, followed by a space and the filename, and exit. The program should keep track of the number of lines, the number of non-blank lines, the number of words, and the number of integers read from the file.
Chapter 13 Solutions
STARTING OUT WITH C++ MPL
Ch. 13.1 - Name three different C++ classes that can be used...Ch. 13.1 - Name three different C++ classes that can be used...Ch. 13.1 - What is the purpose of the second parameter to the...Ch. 13.1 - Why is it important for a program to close an open...Ch. 13.1 - Which file open flag causes all output to take...Ch. 13.1 - Which file open flag causes the contents of an...Ch. 13.1 - What happens if ios: :out is used by itself to...Ch. 13.1 - What happens if ios::out is used by itself to open...Ch. 13.1 - Write a sequence of C++ statements that reads in...Ch. 13.1 - Write a sequence of C++ statements that reads in...
Ch. 13.1 - Show how to use the constructor of the fstream...Ch. 13.1 - Consider two parallel arrays of the same size, one...Ch. 13.3 - Make the required changes to the following program...Ch. 13.3 - Describe the purpose of the eof member function.Ch. 13.3 - Assume the file input.txt contains the following...Ch. 13.3 - Describe the difference between reading a file...Ch. 13.3 - Describe the difference between the getline...Ch. 13.3 - Describe the purpose of the put member function.Ch. 13.3 - What will be stored in the file out.dat after the...Ch. 13.3 - The following program skeleton, when complete,...Ch. 13.5 - Write a short program that opens two files...Ch. 13.5 - How would the number 479 be stored in a text file?...Ch. 13.5 - Describe the differences between the write member...Ch. 13.5 - What arc the purposes of the two arguments needed...Ch. 13.5 - What are the purposes of the two arguments needed...Ch. 13.5 - Describe the relationship between fields and...Ch. 13.5 - Prob. 13.27CPCh. 13.7 - Describe the difference between the seekg and the...Ch. 13.7 - Describe the difference between the tellg and the...Ch. 13.7 - Describe the meaning of the following file access...Ch. 13.7 - What is the number of the first byte in a file?Ch. 13.7 - Briefly describe what each of the following...Ch. 13.7 - Describe the mode that each of the following...Ch. 13 - Prob. 1RQECh. 13 - Before a file can be used, it must first beCh. 13 - When a program is finished using a file, it shouldCh. 13 - The__________ header file is required for file I/O...Ch. 13 - Prob. 5RQECh. 13 - The_____________ file stream data type is for...Ch. 13 - The____________ file stream data type is for input...Ch. 13 - The ______ file stream data type is for output...Ch. 13 - Write a statement that defines a file stream...Ch. 13 - Write a statement that defines a file stream...Ch. 13 - Write a statement that defines a file stream...Ch. 13 - Write two statements that use the people file...Ch. 13 - Write two statements that use the pets file stream...Ch. 13 - Write two statements that use the places file...Ch. 13 - If a file fails to open, the file stream object...Ch. 13 - Write a program segment that defines a file stream...Ch. 13 - The same formatting techniques used with ______...Ch. 13 - The ______ member function reports when the end of...Ch. 13 - The ______ function reads a line of text from a...Ch. 13 - The _______ member function reads a single...Ch. 13 - The _____ member function writes a single...Ch. 13 - Prob. 22RQECh. 13 - Prob. 23RQECh. 13 - Prob. 24RQECh. 13 - In C++, _______ provide a convenient way to...Ch. 13 - The _______ member function writes raw binary data...Ch. 13 - The _______ member function reads raw binary data...Ch. 13 - The ______ operator is necessary if you pass...Ch. 13 - In _______ file access, the contents of the file...Ch. 13 - In _____ file access, the contents of a file may...Ch. 13 - The _______ member function moves a files read...Ch. 13 - The ______ member function moves a files write...Ch. 13 - The _______ member function returns a files...Ch. 13 - The _______ member function returns a files...Ch. 13 - The ______ mode flag causes an offset to be...Ch. 13 - The ______ mode flag causes an offset to be...Ch. 13 - The ______ mode flag causes an offset to he...Ch. 13 - A negative offset causes the files read or write...Ch. 13 - Give a pseudocode algorithm for determining the...Ch. 13 - Give a pseudocode algorithm for comparing two...Ch. 13 - Prob. 41RQECh. 13 - Suppose that you have two text files that contain...Ch. 13 - Each of the following programs or program segments...Ch. 13 - File Previewer Write a program that asks the user...Ch. 13 - File Display Program Write a program that asks the...Ch. 13 - Punch Line Write a program that reads and prints a...Ch. 13 - Tail of a File Write a program that asks the user...Ch. 13 - String Search Write a program that asks the user...Ch. 13 - Sentence Filter A program that processes an input...Ch. 13 - File Encryption Filter File encryption is the...Ch. 13 - File Decryption Filter Write a program that...Ch. 13 - Letter Frequencies The letter e is the most...Ch. 13 - Put It Back C++ input stream classes have two...Ch. 13 - Prob. 11PCCh. 13 - Insertion Sort on a File II Modify the program...Ch. 13 - Prob. 13PCCh. 13 - Prob. 14PCCh. 13 - Inventory Program Write a program that uses a...Ch. 13 - Inventory Program Write a program that uses a...Ch. 13 - Group Project 17. Customer Accounts This program...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
?.1 Define the different reference meridians that can be used for the direction ofa line.
Elementary Surveying: An Introduction To Geomatics (15th Edition)
What is denormalization?
Database Concepts (8th Edition)
What are the advantages in implementing a language with a pure interpreter?
Concepts Of Programming Languages
True or False: When a class contains an abstract method, the class cannot be instantiated.
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Determine the moment of each of the three forces about point A.
INTERNATIONAL EDITION---Engineering Mechanics: Statics, 14th edition (SI unit)
The overhang beam is subjected to the uniform distributed load having an intensity of w=50 kN/m. Determine the ...
Mechanics of Materials (10th Edition)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- I opened a CSV file in C++ and the headings of the file are Name, Class, Subject, Standing (in same order). I want to output the file on the console in ascending order of Subject (later I will be performing insert sort). how do I make it in ascending order of Subject which is third column. please add code.arrow_forwardWrite a program that reads words from a file (filename given as a string parameter) and prints the occurance of each word(case insensitive). And print the words in alphabetical order. For example, if the file contains text Love is free free is love then the function should print free:2 is:2 love:2 def count_word(filename): # YOUR CODE HERE raise NotImplementedError()arrow_forwardThis needs to be written in C programming. It is a practice program and it is not graded. So if you could help that would be great. I just need someone to show me what the program looks like.arrow_forward
- Write a C++ program that opens three files (i.e. s1.txt, s2.txt, and s3.txt) and reads the data of three students. Each file contains the student first name and last name separated by a space and the student grades in three subjects as double floating-point numbers on the next line. The program should output the data in table format such that the data of each student is displayed on one line. The data of the students is ordered in the table alphabatically according to their names. The last column in the table contains the average grade of each student. The last row in the table contains the maximum grade in each subject. Notice that the width of the first column in the table is 20 and its is aligned to the left. All remaining columns have width of 7 and their data is aligned to the right. Also Notice, that all the numbers in the table must be displayed with exactly two decimal digits. IMPORTANT NOTES . Do not add any cout statements except for the final outputs as shown in the sample…arrow_forwardpls code in pythonplagiarism: This Boolean function takes two filenames. If any line occurs in both files, return True.If not, return False. I suggest using nested loops. With nested loops, we call the loop that is in thebody of the other loop, the "inner loop". The loop that contains the inner loop is the "outer loop". Openthe second file inside the outer loop:for line1 in file1:file2 = open(fname2)for line2 in file2:Python only lets you read the file once per open, so you need this order of instructions. Make sure yourreturn False is outside of both loops. Otherwise, you will only compare the first two lines of thefiles. Make sure you close the file that gets read repeatedly after the inner loop but still inside the outerloop.Here is some (more complete) pseudocode to get you started:open file 1for line1 in file 1open file 2for line2 in file 2:if line1 == line2:return Trueclose file 2return Falsearrow_forwardIn this assignment, you will create a Java program to read undergraduate and graduate students from an input file, sort them, and write them to an output file. This assignment is a follow up of assignment 5. Like assignment 5, your program will read from an input file and write to an output file. The input file name and the output file name are passed in as the first and second arguments at command line, respectively. Unlike assignment 5, the Student objects are sorted before they are written to the output file. • The program must implement a main class, three student classes (Student, UndergradStudent, GradStudent), and a Comparator class called StudentIDComparator. • The StudentIDComparator class must implement the java.util.Comparator interface, and override the compare() method. Since the Comparator interface is a generic interface, you must specify Student as the type parameter when defining the StudentIDComparator class, i.e., public class StudentIDComparator implements…arrow_forward
- Write a program in C++ that creates a file and writes data into that file column wise. The problem is that there is some data that I want to keep there permantely and I do not want to replace it every time. For example this format: TIME DAY MONTH YEAR 01:25 07 JUNE 2008 14:00 30 MARCH 2019 I have (TIME/ DAY/ MOTH/ YEAR) and I want to write that first and that any data that I add later is written under that and so on. If I want to add the row (05:05/ 10/ July/ 2000) following the pattern. Write code that checks if the file has data and write that data under the lines you already have.arrow_forwardPlease help with this exercise I found on the internet. I want to know the solution, also with explaining( can use # in the coding),thanksarrow_forwardcan you show me this in pythonarrow_forward
- please use spyderarrow_forwardImplement a function wordCount, which reads a text file, and returns thenumber of words in the file. You can assume the file only contains thealphabet characters and the space character. However there may be morethan one space character between two words, so “abc abc” and “abc abc”,for example, are both two words. int wordCount ( const char * filename ) {}arrow_forwardMatlab Exercise: Create a wav file of your own voice by reading and recording the letters A, B, C and D. (You may use the application 'audacity' for this purpose Read the file from matlab. Find out the size of the matrix. Plot the wave file. Find out the length of recording from the plot. Play the sound file from matlab Work on the matrix so that the letters B and D will he audible on one track only while playing Work agaitn on the matrix so that the letters B and D are elitminated cumpletely from the wave file. In MATLABarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
C - File I/O; Author: Tutorials Point (India) Ltd.;https://www.youtube.com/watch?v=cEfuwpbGi1k;License: Standard YouTube License, CC-BY
file handling functions in c | fprintf, fscanf, fread, fwrite |; Author: Education 4u;https://www.youtube.com/watch?v=aqeXS1bJihA;License: Standard Youtube License