Question: Using Files - String or word processing Based on a problem from Nell Dale, Chip Weems and Mark Headington, Programming and Problem Solving with C++
Using Files - String or "word" processing Based on a problem from Nell Dale, Chip Weems and Mark Headington, Programming and Problem Solving with C++ Write a program that prints out the number of words in a file of text. We will define a word to be any sequence of non-whitespace characters. So "hi&there...mom" would be considered a single word. Solve this problem by using a string variable into which you input each word as a string. Here are some hints for assignment 5.3. Your program should ask the user for the name of the file to count words in (see the Chapter #13 section 13.1 in the Gaddis text titled "Using Variable File Names" on page 831). It should loop until the user types "quit" for the name of the file. Turn in your source code, followed by an output which has the user entering these 5 input files: file 1 | file 2 | file 3 | file 4 | file 5 File 1: This &%file should!!,... have exactly 7 words. File 2: This is a &%file that should!!,... have exactly 10 words. File 3: This is a &%file that should!!,... This file must have several spaces at the end of the file. have 21 words. File 4: This &%file that has!!,... ' This file must have several spaces at the end of the file. 19 words. File 5: Mr. &%Brown can moo!!,... ' can you? This file should have several blank lines before the end of the file. 22 words.
I tried to do
#include
and named all files in input1, input2, and so on
but the result comes out as
Enter the name of file (enter quit to exit): input1
Assertion failed: (inFile), function main, file /Users/Bosco/Desktop/school/spring 18/A5.3/A5.3/a5_3.cpp, line 34.
(lldb)
I don't know what is wrong can anyone help
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
