EBK STARTING OUT WITH C++
9th Edition
ISBN: 9780134996066
Author: GADDIS
Publisher: PEARSON CUSTOM PUB.(CONSIGNMENT)
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 12, Problem 65RQE
fstream file(ios::in | ios::out);
file.open("info.dat") ;
if (! file)
{
cout ≪ "Could not open file.\n";
}
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write code that opens an output file with the filename number_list.txt, but does not erase the file’s contents if it already exists.
Word Puzzle GameIn this assignment is only for individual. You are going to decode the scrambled word into correct orderin this game. One round of play is as follows:1. Computer reads a text file named words.txt2. Computer randomly picks one word in the file and randomly scrambles characters in the wordmany times to hide the word3. Computer displays the scrambled word to user with indexes and gives the user options to1. Swap two letters in word based on index given2. Solve the puzzle directly3. Quit the game4. If a player chooses to swap letters, the computer reads two indexes and swaps the letters. Thegame resume to step 3 with the newly guessed word. If the resulted word after swapping is thesecret word, the game is over.5. If a user chooses to solve directly, computer prompts the user to enter the guessed word. If it’scorrect, the game is over, otherwise goes to step 3.6. After game is over, display how many times the player has tried to solve the puzzle.The following is sample…
FILE* inFile = fopen("filenam.txt", "r");
Given the above code segment, which of the following would output "FILE NOT FOUND" if the file could not be opened?
Group of answer choices
if(inFile == NULL)
{
printf("FILE NOT FOUND");
}
if(inFile)
{
printf("FILE NOT FOUND");
}
if(!inFile->is_open())
{
printf("FILE NOT FOUND");
}
None of these
=============
What does sscanf do?
Group of answer choices
Reads from a file
Reads from a keyboard
Reads from a string
Writes to a screen
===========
What comes first in the software development life cycle?
Group of answer choices
Algorithm design
Identifying the problem
Coding
Testing
Chapter 12 Solutions
EBK STARTING OUT WITH C++
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
The following is a short program that computes the volume of a sphere given the radius. It will compile and run...
Problem Solving with C++ (9th Edition)
For each of the following activities, give a PEAS description of the task environment and characterize it in te...
Artificial Intelligence: A Modern Approach
Give the definitions of three accessor methods that you can use instead of the single accessor method getFirst ...
Java: An Introduction to Problem Solving and Programming (7th Edition)
State whether each of the following is true or false. If false, explain why. The remainder operator (%) can be ...
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
What will the following program display? public class ReviewQuestion5 { public static void main(String[] args) ...
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Identify and fix the errors in the following code: 1 public class Test { 2 public static void main(Str1ng[] arg...
Introduction to Java Programming and Data Structures, Comprehensive Version (11th 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
- Music App 1. practise file I/O and exception handling; 2. practise String processing. Aim: Task: Create a Java application that transcripts a simple song score sheet. The program asks user for filename of a text file that contains a simple song score sheet in this format: Sample song score sheet 1, song1.txt: #simple song with assumed time signature = 4 d1mls202s 1mld2o2 d1rimlfls 301s1f1m1rld4 Lines beginning with a hash #' is a comment line. A song contains one or more lines of musical notes, d, r, m, f, s, l, tand also o meaning "Off" or rest. Each single character note is followed by a single digit integer in [1 – 4], denoting the duration of the note in number of beats. After transcription, the program outputs the melody on the screen as well as to another text file: Melody output 1, on screen AND in melody_song1.txt: #simple song with assumed time signature Do Me So- Off- So Me Do Re Me Fa| So-- Off = 4 Do- Off- | So Fa Me Re Do--- | The default time signature is 4 beats per…arrow_forwardWrite a code segment that creates an ifstream object named infile, opens the numbers.txt file created by the code in the previous question, and associates it with infile. The code should then use a loop to read and display all of the numbers in the file before closing it.arrow_forwardPythonarrow_forward
- In C# create an application that writes a series of random numbers to a file. Each random number should be in the range of 1 through 100. The application should let the user specify how many random numbers the file will hold.arrow_forwardOption 2: Display the Record of a particular PatientWhen a user selects option 2, The main function prompts for and reads a PatientID. Then it calls the thefunction getPatient(patientID), which then searches for this PatientID in the text-file. If the Patient is notfound, an appropriate error message is displayed, otherwise; the Patient’s information is displayed. Inboth cases, the option waits for the Enter key to be pressed before returning control to the main menu.Please select your choice: 2Enter Patient ID: 1002Patient ID Patient Name Weight Ave. Weight Visits1002 Majed Sameer 18 .6 18 .2 2Press Enter key to continue . . .Please select your choice: 2Enter Patient ID: 1552Error: Invalid PatientPress Enter key to continue . . . Option 3: Display all Patient WeightIt prompts for- and reads a maximum weight from the user. Then it displays all patients with weight lessthan or equal to the give weight. Also, it displays the percentage weight increase (with a + sign) ordecrease (with a…arrow_forward* The ofstream class then default mode of opening the file are ios::in ios::out O ios::outlios::trunk O ios::inlios::trunc Oarrow_forward
- Write a code segment that creates an ofstream object named outfile, opens a file named numbers.txt, and associates it with outfile. The code should then use a loop to write the numbers 1 through 100 to the file before closing it.arrow_forward#include <stdio.h> /* mycat: concatenate files */ void filecopy(FILE *, FILE *); int main(int argc, char *argv[]){ FILE *fp; if (argc == 1){ /* no args, copy standard input */ filecopy(stdin, stdout); }else{ while (--argc > 0){ if ((fp = fopen(*++argv, "r")) == NULL) { printf("cat: cannot open %s\n", *argv); return 1; } else { filecopy(fp, stdout); fclose(fp); } } } return 0; } /* filecopy: copy file ifp to file ofp */ #include <stdio.h> void filecopy(FILE *ifp, FILE *ofp) { int c; while ((c = getc(ifp)) != EOF) putc(c,ofp); }arrow_forward/** * The file path that is IOManager read and write an object from. This *file location will is used by @link #read()} and {@link #write(Object)}. * This method may not return a null value. If the path is not set this should return an empty string. * @param path The file location to be read and written to } # *1 public string getPath(); otFoundException, IllegalArgumentE; /* * Reads the object saved in the file located at the path returned by {@link #getPatF * @return An object saved in the file. 3* @throws IOException when something goes wrong in the IO process @throws ClassNotFoundException If the object located at the is a class that is not * by this version of your software @throws Illegal state Exception If the file path has not been set yet * */ public T read() throws IOException, ClassNotFoundException, IllegalStateException; /** * Writes and object to saved at the file located at the path returned by {@link #getPath( @param object The object saved in the file * @throws…arrow_forward
- İn pythonarrow_forwardmy_list.txt: 150+250 Which of the following code blocks writes the sum (400) in a new line of the file? a. with open('my_list.txt', 'r+') as file: line = file.readline() sum = 0 for i in line.split('+'): sum = sum + i file.write(str(sum)) b. with open('my_list.txt', 'r+') as file: line = file.readline() for i in line.split('+'): sum = sum + int(i) file.write(str(sum)) c. with open('my_list.txt', 'r+') as file: line = file.readline() sum = 0 for i in line.split(): sum = sum + int(i) file.write(str(sum)) d. with open('my_list.txt', 'r+') as file: line = file.readline() sum = 0 for i in line.split('+'): sum = sum + int(i) file.write(str(sum))arrow_forwardTo write an object to a file, you use the ________ function of the ________ module.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
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