Question: String nameOfFile and integer onionCount are read from input. Open nameOfFile as an output file. If the file fails to open: Use cout to output

String nameOfFile and integer onionCount are read from input. Open nameOfFile as an output file. If the file fails to open:
Use cout to output nameOfFile followed by ": file-open operation failure" and a newline.
Terminate the program with 1 as the return value without writing to the file.
Otherwise, write onionCount followed by " onions" and a newline to the opened file.
Ex: If the input is note.txt 19, then note.txt contains:
19 onions
#include
#include
using namespace std;
int main(){
ofstream outFS;
string nameOfFile;
int onionCount;
cin >> nameOfFile;
cin >> onionCount;
/* Your code goes here */
outFS.close();
return 0;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!