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
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...
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](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fe2932faa-b49a-4196-8420-f277821525a8%2Fea0943c5-d5d8-4855-ae52-b804e0b5e8df%2Fyohic7_processed.png&w=3840&q=75)
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

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images

Recommended textbooks for you

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 Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

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 Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

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
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education

Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY