Starting Out with C++ from Control Structures to Objects (8th Edition)
8th Edition
ISBN: 9780133769395
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 12, Problem 57RQE
T F The same output formatting techniques used with cout may also be used with file stream objects.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Image Creation
Write a C program to create a binary ppm file with 1000 by 1000 pixels. It uses five different
colors to draw a picture. See the screen shot. You can choose any five colors. The corners of the
central part should use the 250th and 750th row/column.
Restrictions on the file format:
no comment line after the file type specification
width (number of columns) and height (number of rows) formatted in ASCII decimal in
the second line, separated by a space
maximal value of color components given in the third line
A picture.jpg v
Q Search
File Iteration: Introduction
A text file is essentially a sequence of lines. Here is a typical coding pattern for processing each line of a file in turn:
Open the file for reading.
Use a for loop to iterate over the lines of text, executing a block of one or more statements to process each line.
Close the file.
Finish processing (print, return, etc.) if needed
NOTE: You will need to use this pattern, or some variation of it, to solve the remaining coding problems in this assignment.
As the following for loop iterates through each line of the file, the loop variable (`line`) represents the current line of the file as a string of characters.
myFile = open("someTextFile.txt", "r") for line in myFile: do something on each iteration do a second thing on each iteration etc... myFile.close()
PROBLEM: Read a string from standard input using python. Then, iterate over a text file called "cards.txt" and, for each line of the file that starts with the string read from standard input,…
C Standard Library
The C library stdio.h provides several key input/output functions. For questions 1-13, please
match the names to the best descriptions of their functions.
fclose()
feof()
fopen() c. Reads formatted input from a file
fprintf() d. Reads formatted input from stdin
printf() e. Reads a line from a file and stores it into a string
sprintf() f. Reads a line from stdin and stores it into a string
fscanf() g. Writes a string (plus newline character) to stdout
scanf() h. Writes a string (plus newline character) to a file
sscanf() i. Test the end-of-file indicator for a file
fgets() j. Reads formatted input from a string
fputs() k. Sends formatted output to a string
gets() l. Close a file
puts() m. Opens a filename using the given mode
a. Sends formatted output to a file
b. Sends formatted output to stdou
c. Reads formatted input from a file
d. Reads formatted input from stdin
e. Reads a line from a file and stores it into a string
f. Reads a line from stdin and stores…
Chapter 12 Solutions
Starting Out with C++ from Control Structures to Objects (8th Edition)
Ch. 12.1 - Which file access flag would you use if you want...Ch. 12.1 - Prob. 12.2CPCh. 12.1 - Assuming diskInfo is an fstream object, write a...Ch. 12.1 - Assuming diskInfo is an fstream object, write a...Ch. 12.1 - Assuming diskInfo is an fstream object, write a...Ch. 12.1 - Write a statement that defines an fstream object...Ch. 12.5 - Assume the file input.txt contains the following...Ch. 12.5 - Describe the difference between reading a file...Ch. 12.5 - What will be stored in the file out.txt after the...Ch. 12.10 - Describe the difference between the seekg and the...
Ch. 12.10 - Describe the difference between the tellg and the...Ch. 12.10 - Describe the meaning of the following file access...Ch. 12.10 - What is the number of the first byte in a file?Ch. 12.10 - Briefly describe what each of the following...Ch. 12.10 - Describe the mode that each of the following...Ch. 12 - What capability does the fstream data type provide...Ch. 12 - Which file access flag do you use to open a file...Ch. 12 - Assume the file data.txt already exists, and the...Ch. 12 - How do you combine multiple file access flags when...Ch. 12 - Should file stream objects be passed to functions...Ch. 12 - Under what circumstances is a file stream objects...Ch. 12 - Under what circumstances is a file stream objects...Ch. 12 - Under what circumstances is a file stream objects...Ch. 12 - How do you read the contents of a text file that...Ch. 12 - What arguments do you pass to a file stream...Ch. 12 - What arguments do you pass to a file stream...Ch. 12 - Prob. 12RQECh. 12 - Prob. 13RQECh. 12 - How do you get the byte number of a files current...Ch. 12 - If a program has read to the end of a file, what...Ch. 12 - How do you determine the number of bytes that a...Ch. 12 - How do you rewind a sequential-access file?Ch. 12 - The _____ file stream data type is for output...Ch. 12 - If a file fails to open, the file stream object...Ch. 12 - The same formatting techniques used with...Ch. 12 - The _____ function reads a line of text from a...Ch. 12 - The ____________ member function reads a single...Ch. 12 - The ________member function writes a single...Ch. 12 - Prob. 24RQECh. 12 - __________ files contain data formatted as...Ch. 12 - Prob. 26RQECh. 12 - Prob. 27RQECh. 12 - The ___________ member function writes raw binary...Ch. 12 - The __________ member function reads raw binary...Ch. 12 - Prob. 30RQECh. 12 - In ___________ file access, the contents of the...Ch. 12 - In __________ file access, the contents of a file...Ch. 12 - The _____________ member function moves a files...Ch. 12 - The ___________ member function moves a files...Ch. 12 - The __________ member function returns a files...Ch. 12 - The ___________ member function returns a files...Ch. 12 - The __________ mode flag causes an offset to be...Ch. 12 - The __________ mode flag causes an offset to be...Ch. 12 - The ________ mode flag causes an offset to be...Ch. 12 - A negative offset causes the files read or write...Ch. 12 - Write a statement that defines a file stream...Ch. 12 - Write two statements that use a file stream object...Ch. 12 - Write two statements that use a file stream object...Ch. 12 - Write two statements that use a file stream object...Ch. 12 - Write a program segment that defines a file stream...Ch. 12 - Write code that opens the file data.txt for both...Ch. 12 - Write code that determines the number of bytes...Ch. 12 - The infoFile file stream object is used to...Ch. 12 - T F Different operating systems have different...Ch. 12 - T F fstream objects are only capable of performing...Ch. 12 - T F ofstream objects, by default, delete the...Ch. 12 - T F ifstream objects, by default, create a file if...Ch. 12 - T F Several file access flags may be joined by...Ch. 12 - T F A file may be opened in the definition of the...Ch. 12 - T F If a file is opened in the definition of the...Ch. 12 - T F A file stream objects fail member function may...Ch. 12 - T F The same output formatting techniques used...Ch. 12 - T F The operator expects data to be delimited by...Ch. 12 - T F The getline member function can be used to...Ch. 12 - T F It is not possible to have more than one file...Ch. 12 - T F Binary files contain unformatted data, not...Ch. 12 - T F Binary is the default mode in which files are...Ch. 12 - T F The tellp member function tells a file stream...Ch. 12 - T F It is possible to open a file for both input...Ch. 12 - fstream file(ios::in | ios::out);...Ch. 12 - ofstream file; file.open (info.dat, ios::tin); if...Ch. 12 - fstream file("info.dat"); if (!file) { cout ...Ch. 12 - fstream dataFile("info.dat", ios:in | ios:binary);...Ch. 12 - Prob. 69RQECh. 12 - fstream dataFi1e("info.dat", ios:in); char...Ch. 12 - Prob. 71RQECh. 12 - fstream inFile("info.dat", ios:in); int x;...Ch. 12 - File Head Program Write a program that asks the...Ch. 12 - File Display Program Write a program that asks the...Ch. 12 - Punch Line Write a program that reads and prints a...Ch. 12 - Tail Program Write a program that asks the user...Ch. 12 - Line Numbers (This assignment could be done as a...Ch. 12 - String Search Write a program that asks the user...Ch. 12 - Sentence Filter Write a program that asks the user...Ch. 12 - Array/File Functions Write a function named...Ch. 12 - File Encryption Filter File encryption is the...Ch. 12 - File Decryption Filter Write a program that...Ch. 12 - Prob. 11PCCh. 12 - Prob. 12PCCh. 12 - Inventory Program Write a program that uses a...Ch. 12 - Inventory Screen Report Write a program that reads...Ch. 12 - Average Number of Words If you have downloaded...Ch. 12 - Customer Accounts This program should be designed...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Look at the following pseudocode. If it were a real program, what would it display? Declare Integer number = 5 ...
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
When displaying a Java applet, the browser invokes the _____ to interpret the bytecode into the appropriate mac...
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
Rock, Paper, Scissors Modification Programming Exercise 11 in Chapter 6 asked you to design a program that play...
Starting Out with Programming Logic and Design (4th Edition)
What must be done to translate a posttest loop expressed in the form repeat: (. . .) until (. . .) into an equi...
Computer Science: An Overview (12th Edition)
Consider the following two relations for Millennium College: STUDENT(StudentID, StudentName, CampusAddress, GPA...
Modern Database Management (12th Edition)
1. Read the problem statement. 2. Formulate the algorithm using pseudocode and top-down, stepwise refinement. 3...
Java How To Program (Early Objects)
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
- C programming language Topic : Input/Output Program : Product list (product.c) Definition : The program reads a series of items form a file and displays the data in columns. The program obtains the file name from the command line. Each line of the file will have the following form: item, mm-dd-yyyy, price For example, suppose that the file contains the following lines: 123, 12.00, 12/25/2006 124, 18.30, 1/10/2020 Expected output: Item Unit Purchase Price Date 123 $ 12.00 12/25/2006 124 $ 18.30 1/10/2020arrow_forwardPYTHON without def function Problem Statement Suppose an input file (called "paragraph.txt") contains a paragraph of text. Read in the file and then count/print the number of times the word "book" is in the file. Hint: Punctuation should be ignored, i.e., "book?" and "book!" should increase the count. The program should also be case-insensitive. Sample Input (File paragraph.txt) I have a book. It's called Harry Potter. It's a pretty good book! Do you want to buy my BOOK? Sample Output The word 'book' appears 3 time(s).arrow_forwardQ3:IN SML language how would I write a string to integer function that inputs a filename and returns zero if the contents inside the file is blank.arrow_forward
- Merge two files (1 point) Write a program that reads the content of two files “text1.txt” and “text2.txt" line by line and merges them into another file called “merge12.txt". You can safely assume that the input is valid. IN C PROGRAMMINGarrow_forwardProgramming Language:- Carrow_forwardPYTHON without def function Problem Statement Assume an input file (called "numbers.txt") contains a number on each non-blank line of the file. Read in the file and then print out the sum of all the numbers read. The sum should be rounded up to 1 decimal. Sample Input (File numbers.txt) 1.0 2.0 3.25 4.0 Sample Output 10.3arrow_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 PtrSystems ArchitectureComputer ScienceISBN:9781305080195Author:Stephen D. BurdPublisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning
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