CJCoding With Joseph
15free / daySign inCreate account
TitleTopicsAction
574
Read the First WordA text file contains words separated by spaces and newlines, for example: hello...
easy○ Not Started
Streamsifstream
Solve
575
Read One Integer from a FileA text file starts with a whole number, for example: 42 Write a function `int ...
easy○ Not Started
Streamsifstream
Solve
576
Did the File Open?Write a function `bool canOpen(const string& filename)` that tries to open the f...
easy○ Not Started
Streamsifstream
Solve
577
Count LinesA text file contains one item per line, for example: red green blue Write a fu...
easy○ Not Started
Streamsifstream
Solve
578
Sum Numbers in a FileA text file contains whole numbers separated by spaces or newlines, for example:...
easy○ Not Started
Streamsifstream
Solve
579
Read the First LineWrite a function `string firstLine(const string& filename)` that returns the ent...
easy○ Not Started
Streamsifstream
Solve
580
Print a FileWrite a function `void printFile(const string& filename)` that prints every line...
easy○ Not Started
Streamsifstream
Solve
581
Count WordsA text file contains words separated by any mix of spaces and newlines, possibly...
easy○ Not Started
Streamsifstream
Solve
582
Read Mixed ValuesThe starter first writes the single line `Alice 30 5.5` into `person.txt` (that ...
easy○ Not Started
Streamsifstream
Solve
583
Close and ReportThe starter writes `hello` into `notes.txt`, opens it as `ifstream in`, reads on...
easy○ Not Started
Streamsifstream
Solve
598
Write One LineWrite a function `void writeGreeting(const string& filename)` that opens `filena...
easy○ Not Started
Streamsofstream
Solve
599
Write Numbers 1 to 5Write a function `void writeNumbers(const string& filename)` that opens `filenam...
easy○ Not Started
Streamsofstream
Solve
600
Write a Vector on One LineWrite a function `void writeVector(const string& filename, const vector<int>& v)...
easy○ Not Started
Streamsofstream
Solve
601
Check Open Before WritingWrite a function `bool saveText(const string& filename, const string& text)` tha...
easy○ Not Started
Streamsofstream
Solve
602
Append a LineWrite a function `void appendLine(const string& filename, const string& line)` t...
easy○ Not Started
Streamsofstream
Solve
603
Write Then Read BackThe program opens the file `words.txt` with an `ofstream` called `out`, closes i...
easy○ Not Started
Streamsofstream
Solve
604
Save a PersonWrite a function `void savePerson(const string& filename, const string& name, in...
easy○ Not Started
Streamsofstream
Solve
605
Overwrite an Existing FileWrite a function `void overwrite(const string& filename, const string& text)` th...
easy○ Not Started
Streamsofstream
Solve
606
Close Before ReopeningThe program writes the line `done` to `status.txt` with an `ofstream` called `ou...
easy○ Not Started
Streamsofstream
Solve
607
Write a Formatted PriceWrite a function `void writePrice(const string& filename, double p)` that opens ...
easy○ Not Started
Streamsofstream
Solve
622
Print to an ostream ParameterWrite a function `void printHello(ostream& out)` that writes the text `Hello, st...
easy○ Not Started
Streamsostream
Solve
623
Sum to a StreamWrite a function `void printSum(ostream& out, int a, int b)` that writes the equ...
easy○ Not Started
Streamsostream
Solve
624
operator<< for a ColorA struct `Rgb` with three public ints `r`, `g`, `b` is given. Complete the free ...
easy○ Not Started
Streamsostream
Solve
625
setw Right AlignmentThe variable `int value = 42;` is declared for you. Print `value` right-aligned ...
easy○ Not Started
Streamsostream
Solve
626
Zero Padding with setfillThe variable `int id = 42;` is declared for you. Print `id` padded on the left w...
easy○ Not Started
Streamsostream
Solve
627
Two Decimal PlacesThe variable `double pi = 3.14159;` is declared for you. Print it rounded to exa...
easy○ Not Started
Streamsostream
Solve
628
Left-Aligned ColumnThe variable `string header = "Name";` is declared for you. Print it left-aligne...
easy○ Not Started
Streamsostream
Solve
629
Return the Stream for ChainingWrite a function `ostream& printPair(ostream& out, int a, int b)` that writes `(...
easy○ Not Started
Streamsostream
Solve
630
cout Is an ostreamThe starter declares `ostream& out = cout;` and `int total = 5;`. Using `out` (n...
easy○ Not Started
Streamsostream
Solve
631
Print a Vector to a StreamWrite a function `void printVec(ostream& out, const vector<int>& v)` that writes...
easy○ Not Started
Streamsostream
Solve
646
fstream in Write ModeWrite a function `void writeWithFstream(const string& filename, const string& te...
easy○ Not Started
Streamsfstream
Solve
647
fstream in Read ModeWrite a function `string readWithFstream(const string& filename)` that opens `fi...
easy○ Not Started
Streamsfstream
Solve
648
Append with fstreamWrite a function `void appendFs(const string& filename, const string& line)` tha...
easy○ Not Started
Streamsfstream
Solve
649
in-and-out Needs an Existing FileWrite a function `bool openReadWrite(const string& filename)` that opens `filena...
easy○ Not Started
Streamsfstream
Solve
650
Write, Seek, ReadThe program below opens `note.txt` with an `fstream` in `ios::in | ios::out | io...
easy○ Not Started
Streamsfstream
Solve
651
tellg After ReadingThe program below writes the eleven characters `hello world` (no newline) into `...
easy○ Not Started
Streamsfstream
Solve
652
File Size with seekg/tellgWrite a function `long fileSize(const string& filename)` that opens `filename` w...
easy○ Not Started
Streamsfstream
Solve
653
Reset a File with ios::truncWrite a function `void resetFile(const string& filename)` that opens `filename` ...
easy○ Not Started
Streamsfstream
Solve
654
Count Reads Until FailureThe program below writes `5 10 15` into `numbers.txt` and opens it for reading w...
easy○ Not Started
Streamsfstream
Solve
655
Reuse One fstream ObjectThe program below opens `data.txt` for writing with an `fstream`, writes the num...
easy○ Not Started
Streamsfstream
Solve
584
Largest Number in a FileA text file contains one or more integers separated by spaces or newlines, for e...
medium○ Not Started
Streamsifstream
Solve
585
Number Each LineWrite a function `void printNumbered(const string& filename)` that prints every ...
medium○ Not Started
Streamsifstream
Solve
586
Line Containing a WordWrite a function `int lineOf(const string& filename, const string& word)` that r...
medium○ Not Started
Streamsifstream
Solve
587
Average with Missing-File BranchWrite a function `void printAverage(const string& filename)`. If the file cannot...
medium○ Not Started
Streamsifstream
Solve
588
Parse Name,Score LinesA file holds one record per line in the form `name,score` with no spaces around ...
medium○ Not Started
Streamsifstream
Solve
589
Longest LineWrite a function `string longestLine(const string& filename)` that returns the l...
medium○ Not Started
Streamsifstream
Solve
590
Count a Character with getWrite a function `int countChar(const string& filename, char c)` that returns ho...
medium○ Not Started
Streamsifstream
Solve
591
Read a Config ValueA configuration file holds one `key=value` pair per line with no spaces around t...
medium○ Not Started
Streamsifstream
Solve
592
Skip the Header LineThe first line of the file is a text header that must be skipped; every line aft...
medium○ Not Started
Streamsifstream
Solve
593
Lines Containing TextWrite a function `vector<string> linesContaining(const string& filename, const s...
medium○ Not Started
Streamsifstream
Solve
608
Squares TableWrite a function `void writeSquares(const string& filename, int n)` that opens `...
medium○ Not Started
Streamsofstream
Solve
609
Write Only EvensWrite a function `int writeEvens(const string& filename, const vector<int>& v)` ...
medium○ Not Started
Streamsofstream
Solve
610
Copy a FileWrite a function `bool copyFile(const string& src, const string& dst)` that copi...
medium○ Not Started
Streamsofstream
Solve
611
Event LogWrite a function `void logEvent(const string& filename, const string& msg)` that...
medium○ Not Started
Streamsofstream
Solve
612
Save stdin UppercasedRead every line from standard input until the input ends, convert each line to u...
medium○ Not Started
Streamsofstream
Solve
613
Aligned Table to FileWrite a function `void writeTable(const string& filename, const vector<pair<stri...
medium○ Not Started
Streamsofstream
Solve
614
Write CSVWrite a function `void writeCsv(const string& filename, const vector<string>& na...
medium○ Not Started
Streamsofstream
Solve
615
Receipt with TotalWrite a function `void writeReceipt(const string& filename, const vector<double>...
medium○ Not Started
Streamsofstream
Solve
616
Truncate or AppendWrite a function `void save(const string& filename, const string& text, bool app...
medium○ Not Started
Streamsofstream
Solve
617
Multiplication Grid to a FileWrite a function `void writeGrid(const string& filename, int n)` that opens `fil...
medium○ Not Started
Streamsofstream
Solve
632
operator<< for MoneyA class `Money` that stores a whole number of cents is given, together with a fr...
medium○ Not Started
Streamsostream
Solve
633
Table Row HelperWrite a function `void printRow(ostream& out, const string& name, int qty, doubl...
medium○ Not Started
Streamsostream
Solve
634
Polymorphic print(ostream&)An abstract base class `Shape` is given in the starter with the pure virtual met...
medium○ Not Started
Streamsostream
Solve
635
Percent FormatterWrite a function `void printPercent(ostream& out, double ratio)` that takes a ra...
medium○ Not Started
Streamsostream
Solve
636
operator<< for PlaylistA class `Playlist` holding a `vector<string>` of song names is given, together w...
medium○ Not Started
Streamsostream
Solve
637
Receipt to Any StreamWrite a function `void receipt(ostream& out, const vector<pair<string, double>>&...
medium○ Not Started
Streamsostream
Solve
638
Chainable BannerWrite a function `ostream& banner(ostream& out, const string& title)` that write...
medium○ Not Started
Streamsostream
Solve
639
Hex and DecimalWrite a function `void printHexDec(ostream& out, int n)` that writes `n` in deci...
medium○ Not Started
Streamsostream
Solve
640
boolalpha FlagsWrite a function `void printFlags(ostream& out, bool a, bool b)` that writes `a=...
medium○ Not Started
Streamsostream
Solve
641
Matrix to StreamWrite a function `void printMatrix(ostream& out, const vector<vector<int>>& m)` ...
medium○ Not Started
Streamsostream
Solve
656
Write Then Read in One ObjectWrite a function `int writeAndSum(const string& filename, const vector<int>& v)`...
medium○ Not Started
Streamsfstream
Solve
657
Append Then Count LinesWrite a function `int appendAndCount(const string& filename, const string& line)...
medium○ Not Started
Streamsfstream
Solve
658
Persistent CounterWrite a function `int incrementCounter(const string& filename)` that: 1. tries t...
medium○ Not Started
Streamsfstream
Solve
659
Replace a WordWrite a function `int replaceWord(const string& filename, const string& from, co...
medium○ Not Started
Streamsfstream
Solve
660
Read the Nth Fixed RecordWrite a function `string nthRecord(const string& filename, int n)` that opens `f...
medium○ Not Started
Streamsfstream
Solve
661
Numbered AppendWrite a function `void appendNumbered(const string& filename, const string& msg)...
medium○ Not Started
Streamsfstream
Solve
662
Capitalize the First CharacterWrite a function `void capitalizeFirst(const string& filename)` that opens `file...
medium○ Not Started
Streamsfstream
Solve
663
Notes from stdinWrite a program that reads lines from standard input until the input ends, store...
medium○ Not Started
Streamsfstream
Solve
664
Strip Blank LinesWrite a function `int stripBlankLines(const string& filename)` that removes ever...
medium○ Not Started
Streamsfstream
Solve
665
Reverse Lines in PlaceWrite a function `void reverseLines(const string& filename)` that reverses the o...
medium○ Not Started
Streamsfstream
Solve
724
Ticket Line That Leaves the Stream Untouched`Ticket` is written for you, with a friend declaration for `operator<<`. Define ...
medium○ Not Started
Streamsostream
Solve
725
Receipts Numbered by a Static Counter`Receipt` is written for you with a friend declaration. Define `ostream& operato...
medium○ Not Started
Streamsostream
Solve
594
Grade Book ReportWrite a function `void gradeReport(const string& filename)`. Each line of the fi...
hard○ Not Started
Streamsifstream
Solve
595
Transpose a Matrix FileThe first line of the file holds two integers `R C`: the number of rows and the ...
hard○ Not Started
Streamsifstream
Solve
596
Log Reader ClassCreate a class `LogReader` that loads a log file in its constructor. Each line o...
hard○ Not Started
Streamsifstream
Solve
597
First Differing LineWrite a function `int firstDifference(const string& a, const string& b)` that co...
hard○ Not Started
Streamsifstream
Solve
618
Rotating LoggerCreate a class `Logger` that writes log lines to a file but never lets the file ...
hard○ Not Started
Streamsofstream
Solve
619
Split by ParityWrite a function `void splitByParity(const string& src, const string& evens, con...
hard○ Not Started
Streamsofstream
Solve
620
High Scores Save and LoadCreate a class `HighScores` that keeps a list of (name, score) entries. 1. `voi...
hard○ Not Started
Streamsofstream
Solve
621
Word Counts to FileWrite a function `void writeWordCounts(const string& src, const string& dst)` th...
hard○ Not Started
Streamsofstream
Solve
642
Inventory Report operator<<Build a class `Inventory`: 1. `Inventory()` — starts empty 2. `void add(const st...
hard○ Not Started
Streamsostream
Solve
643
Polymorphic Employee ReportThe starter gives an abstract base class `Employee`: a protected `name`, the con...
hard○ Not Started
Streamsostream
Solve
644
Indented Tree PrinterBuild a class `Node` representing one node of a tree: 1. `Node(const string& nam...
hard○ Not Started
Streamsostream
Solve
645
Restore Stream StateWrite a function `void printMoney(ostream& out, double v)` that writes a dollar ...
hard○ Not Started
Streamsostream
Solve
666
File-Backed Key-Value StoreBuild a class `KVStore` that keeps string keys and values in a text file: one en...
hard○ Not Started
Streamsfstream
Solve
667
Fixed-Width Record EditorBuild a class `RecordFile` that stores names in a binary file as fixed-width rec...
hard○ Not Started
Streamsfstream
Solve
668
Bank Ledger FileBuild a class `Ledger` that records bank transactions in a text file and recompu...
hard○ Not Started
Streamsfstream
Solve
669
Merge Two Files UniquelyWrite a function `int mergeUnique(const string& a, const string& b, const string...
hard○ Not Started
Streamsfstream
Solve