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
Jim is a forensic specialist. He seized a suspect computer from a crime scene, removed the hard drive and bagged it, documented
Andreyy89

Answer: Jim left the computer unattended while shopping for supplies to be used at the next crime scene.

Explanation: While transporting the evidence to a secure location (lab), he left the computer unattended in his car and goes shopping for supplies that will be used in his next crime scenes. This act will give the criminals or their accomplice the opportunity to break into his car and tamper with what ever evidence he might have left behind in his car.

7 0
3 years ago
While a threat intelligence analyst was researching an indicator of compromise on a search engine, the web proxy generated an al
inna [77]

Answer: the corret answer C. The analyst has prefetch enabled on the browser in use.

Explanation:

The analyst has like an indicator which is prefetch enabled on the browser in use.

7 0
3 years ago
Where is the risk of someone intercepting another person’s online activity the greatest?
sergey [27]

social networking site

3 0
3 years ago
Which of the following should you do if you are exhibiting your photographs?
Naddika [18.5K]

I would go with option a

hope that helped

3 0
3 years ago
ATMs are particularly helpful for people on unusual schedules.<br> a. True<br> b. False
larisa86 [58]
True, because if you need money on the go because you dont know where you are going, so you might need the money.
4 0
3 years ago
Read 2 more answers
Other questions:
  • For what show did the actor, whose star is located at 6667 Hollywood Boulevard, earn an Emmy Award for Outstanding Supporting Ac
    10·2 answers
  • Shelly praised Susan via email for how well she executed an employee training program last week. Shelly is engaging in the _____
    6·1 answer
  • . When you have multiple graphics positioned on a page, you can _______________ them so that they are a single graphic instead o
    9·1 answer
  • What is an "immediate preemptive scheduler"?
    15·1 answer
  • Janet received an email from a bank asking for the password for her Internet banking account. She emailed back her password. A f
    12·2 answers
  • Both UDP and TCP use port numbers to identify the destination entity when delivering a message. Give at least one reason for why
    12·1 answer
  • Which is the correct notation to specify the following inheritance?
    8·1 answer
  • Heyyyyyy who likes anime​
    12·2 answers
  • Discuss the advantages of using analogue multi-tester or digital multi-tester over the other.​
    12·1 answer
  • Which three pieces of information should be included in an artist statement? Select all that apply.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!