1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
faltersainse [42]
3 years ago
15

Counting the character occurrences in a file

Computers and Technology
1 answer:
Katena32 [7]3 years ago
5 0

Answer:

hope this helps!

Explanation:

#include <iostream>

#include <fstream>

using namespace std;

void print_histogram(int counter[26])

{

   for(int i = 0; i < 26; ++i){

       cout << (char)(i+97) << " ";

       for(int j = 0; j < counter[i]; ++j){

           cout << (char)254;

       }

       cout << endl;

   }

}

int main()

{

   int counter[26] = {0};

   string filename = "data.txt";

   char byte = 0;

   // opens file in read mode

   ifstream input_file(filename);

   if (!input_file.is_open()) {

       cerr << "Could not open the file - '"

            << filename << "'" << endl;

       return EXIT_FAILURE; // exit if not opened

   }

   // reads every character from the file

   while(input_file.get(byte)){

       if(byte >= 97 && byte <= 122){

           ++counter[byte-97];

       }

   }

   print_histogram(counter); // required print histogram function

   return 0;

}

You might be interested in
What are the characteristics of the Global Address List? Check all that apply.
nignag [31]

Answer:

It is the very last statement (bottom). Also copied to the the client

Explanation:

3 0
3 years ago
Lewis is using a stylus with his touch screen computer in order to draw a
Drupady [299]

Answer:

imput

Explanation:

4 0
3 years ago
Students who finish their homework after school are meeting a. intrapersonal and short-term goals b. normative and short-term go
3241004551 [841]

Answer: a. intrapersonal and short-term goals

Explanation:

Intrapersonal goals are those that we set for ourselves in our minds to accomplish. The students that are finishing their homework after school most probably set that goal in their minds and so meeting it would mean meeting their intrapersonal goals.

Homework is not a long term project but rather a short one that is usually meant to be completed within days. Completing it is therefore a short term goal.

The students who finish their homework after school are therefore accomplishing both their intrapersonal and short-term goals.

6 0
3 years ago
Read 2 more answers
Why must an rodc be able to connect to at least one windows server 2008 or higher domain controller?
raketka [301]
<span>Ensure that at </span>least one<span> writable </span>DC<span> must be running </span>Windows Server 2008<span> or higher before you can deploy a Read-Only-Domain-Controller.</span>
6 0
3 years ago
Assslainsdffddsvvdesdssbhasasco5m
alexandr402 [8]
Hahahahaha I wanna was the day I wanna was the last time I got to
8 0
3 years ago
Read 2 more answers
Other questions:
  • What is the opportunity cost of computers when moving from point A to point B? -15 DVDs b. What is the opportunity cost of compu
    13·1 answer
  • what is the restaurant with the black pom tree and yellow backround three letter name from hi guess the restaurant
    14·2 answers
  • How can improving one’s reasoning skills also improve one’s performance on the job?
    12·2 answers
  • Develop a Matlab program that allows you to plot the entropy of a source with variable output probabilities. We wish to observe
    8·1 answer
  • Write a program that first gets a list of integers from input. The input begins with an integer indicating the number of integer
    7·1 answer
  • A(n) ____ string contacts the data source and establishes a connection with the database using the Data Source Configuration Wiz
    5·1 answer
  • Which of the following refers to a collection of colors, fonts, and effects that can be
    6·1 answer
  • In vehicles equipped with ABS, the driver's foot must remain firmly on the _________ to activate the ABS.
    7·2 answers
  • When copying a pie chart from Calc or Excel to Impress or PowerPoint, once the chart has been pasted, it cannot be edited.
    15·2 answers
  • What's the smallest part of a computer
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!