Write a program that reads several lines from a data file and prints each word o
ID: 3551827 • Letter: W
Question
Write a program that reads several lines from a data file and prints each word of the
file on a separate line of an output file followed by the number of letters in that word.
Also print a count of words in the file on the screen when done. Assume that words are
separated by one or more blanks.
Use at least two functions, one main and one function call (Hint is using a pass by reference function)
Thee following is your sample input data from your input file:
Write a program that reads several lines from a data file and prints each word of the
file on a separate line of an output file followed by the number of letters in that word.
Also print a count of words in the file on the screen when done. Assume that words are
separated by one or more blanks.
The total number of words is 59
Sample output in output file:
Write 5
a 1
program 7
Explanation / Answer
#include #include #include #include #include #define inFile "C:\Users\s\Desktop\FK\Ch8_3.txt" #define outFile "C:\Users\s\Desktop\FK\out.txt" using namespace std; void processData(ifstream&, ofstream&); using namespace std; int main() { ifstream ids; ofstream ods; ids.open(inFile); // I know this opens the files I am reading from and writing to. ods.open(outFile); if (ids.fail()){ cerrRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.