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
Which tool could be used to display only rows containing presidents who served two terms?
kherson [118]

Answer: The tool that could be used to display only the rows containing the presidents who served two terms is the<u> Filter.</u>

Explanation:

If you are using Excel the filter tool is a great way to find the relevant information you are searching for. This will remove all other data from the search results, in this case presidents that only served one term.

The filtering of rows can be used three ways;

  • By the value
  • By the criteria
  • By the format

By using the filter, you can find any phrase, number, dates, etc. Multiple columns can be filtered at the same time. Also, blank cells can be filtered out.

5 0
3 years ago
Read 2 more answers
Select four programs that make up system software.Select four programs that make up system software.
Alenkasestr [34]

Operating system

Boot code

Device drivers

Utilities

5 0
3 years ago
What is missing link describe briefly with an example class 11?
allsm [11]

A missing link is a long-extinct organism that filled in a gap between closely related species that now coexist on Earth, such as between apes and humans or reptiles and birds.

A possible or recent transitional fossil is referred to as the "missing link." In the media and in popular science, it is widely used to describe any novel transitional form. Initially, the expression was used to describe a hypothetical transitional form that existed between anthropoid ancestors and anatomically modern humans. The term was influenced by both the pre-Darwinian evolutionary theory known as the Great Chain of Being and the now discredited notion that simple species are more primitive than sophisticated ones. Human evolutionary phylogenetic tree. Since evolutionary trees only hold information at their tips and nodes, and the rest is relied on conjecture rather than fossil evidence, geneticists have supported the idea of the "missing link." But anthropologists no longer like it because of what it suggests.

Learn more about missing link  from

brainly.com/question/1968231

#SPJ4

6 0
1 year ago
Many subject elements make for simple and streamlined looking images. true or false
sukhopar [10]

Answer:

Explanation:

false. many elements means a complicated picture, not a simple one.

8 0
3 years ago
Ignore this it a temporary note for me: SPSstudents
Westkost [7]

Answer:

okk

Explanation:

3 0
2 years ago
Other questions:
  • How often are computer and user policies applied after a user has logged into a computer?
    15·1 answer
  • To what are multiple servers arranged in racks related
    14·2 answers
  • What is the best definition of the 7x7 rule for maximizing audience comprehension
    13·1 answer
  • Describe markings on a road that indicate that it is safe to pass.
    10·1 answer
  • Which component of a word processor displays the name of the document?
    13·1 answer
  • VEE Physics 2006 E.C
    7·1 answer
  • How many countries don't uses the metric system?​
    12·2 answers
  • The four differences between binary and denary​
    13·1 answer
  • What is MVC architecture in relation to developing in web applications? How
    6·1 answer
  • Can someone help me with this code please explain it to me in simple way
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!