In the last two exercises, you counted words and lines. The wc program counts both, as well as the number of characters in the file. To count the characters & lines, you'll need to use line oriented input and then use the line size (+1) for the character count. For the words, you'll need to use a string stream to count the words in each line. $ wc a.txt b.txt c.txt a.txt 5 32 182 #lines, words, characters b.txt 10 151 587 c. txt does not exist wc.cpp 1 #include 2 #include 3 #include

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
In the last two exercises, you counted words and lines. The wc program counts both, as well as the
number of characters in the file. To count the characters & lines, you'll need to use line oriented input
and then use the line size (+1) for the character count. For the words, you'll need to use a string stream
to count the words in each line.
$ wc a.txt b.txt c.txt
#lines, words, characters
a.txt 5 32 182
b.txt 10 151 587
c.txt does not exist
wc.cpp
1
#include <iostream>
#include <fstream>
#include <sstream>
2
3
4 using namespace std;
5
int main(int argc, char* argv[])
{
6
7
8
9.
10
11
a1.txt
Alice was beginning to get very tired of sitting by her sister on the
2 bank, and of having nothing to do: once or twice she had peeped into the
3
1.
book her sister was reading, but it had no pictures or conversations in
a2.txt
OUT OF ITS WAISTCOAT-POCKET, and looked at it, and then hurried on,
Alice started to her feet, for it flashed across her mind that she had
never before seen a rabbit with either a waistcoat-pocket, or a watch
to take out of it, and burning with curiosity, she ran across the field
1
2
4
а3.txt
So she was considering in her own mind (as well as she could, for the
2 hot day made her feel very sleepy and stupid), whether the pleasure
3
1
of making a daisy-chain would be worth the trouble of getting up and
a4.txt
of making a daisy-chain would be worth the trouble of getting up and
2 picking the daisies, when suddenly a White Rabbit with pink eyes ran
3
1
close by her.
a5.txt
1
There was nothing so VERY remarkable in that; nor did Alice think it so
2
VERY much out of the way to hear the Rabbit say to itself, 'Oh dear!
Oh dear! I shall be late!' (when she thought it over afterwards, it
a6.txt
'Well!' thought Alice to herself, 'after such a fall as this, I shall
2
1
think nothing of tumbling down stairs! How brave they'll all think me at
home! Why, I wouldn't say anything about it, even if I fell off the top
of the house!' (Which was very likely true.)
4
Transcribed Image Text:In the last two exercises, you counted words and lines. The wc program counts both, as well as the number of characters in the file. To count the characters & lines, you'll need to use line oriented input and then use the line size (+1) for the character count. For the words, you'll need to use a string stream to count the words in each line. $ wc a.txt b.txt c.txt #lines, words, characters a.txt 5 32 182 b.txt 10 151 587 c.txt does not exist wc.cpp 1 #include <iostream> #include <fstream> #include <sstream> 2 3 4 using namespace std; 5 int main(int argc, char* argv[]) { 6 7 8 9. 10 11 a1.txt Alice was beginning to get very tired of sitting by her sister on the 2 bank, and of having nothing to do: once or twice she had peeped into the 3 1. book her sister was reading, but it had no pictures or conversations in a2.txt OUT OF ITS WAISTCOAT-POCKET, and looked at it, and then hurried on, Alice started to her feet, for it flashed across her mind that she had never before seen a rabbit with either a waistcoat-pocket, or a watch to take out of it, and burning with curiosity, she ran across the field 1 2 4 а3.txt So she was considering in her own mind (as well as she could, for the 2 hot day made her feel very sleepy and stupid), whether the pleasure 3 1 of making a daisy-chain would be worth the trouble of getting up and a4.txt of making a daisy-chain would be worth the trouble of getting up and 2 picking the daisies, when suddenly a White Rabbit with pink eyes ran 3 1 close by her. a5.txt 1 There was nothing so VERY remarkable in that; nor did Alice think it so 2 VERY much out of the way to hear the Rabbit say to itself, 'Oh dear! Oh dear! I shall be late!' (when she thought it over afterwards, it a6.txt 'Well!' thought Alice to herself, 'after such a fall as this, I shall 2 1 think nothing of tumbling down stairs! How brave they'll all think me at home! Why, I wouldn't say anything about it, even if I fell off the top of the house!' (Which was very likely true.) 4
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY