#include <iostream>
#include<iomanip>
#include <string>
#include <cstring>
using namespace std;
//Function to remove garbage off word
void onlyAlpha(string& str1)
{
string newStr1 ="";
newStr1.reserve(str1.size());
for(string::size_type i = 0; i < str1.size(); i++)
{
if ( isalpha( str1[i] ) )
newStr1.push_back( str1[i] );
}
str1 = newStr1;
}
//A function to determine frequency of letters
void fillFrequency(string str1, int freqcount[], const int alphabet)
{
int position = 0;
for(string::size_type i = 0; i < str1.size(); i++)
{
str1[i] = toupper(str1[i]);
++(freqcount[str1[i] - 'A']);
}
}
//Function to fill new array with new words.
void funfun(string str1[], const int isize, int& countWord)
{
for(int i = 0; i < isize; i++)
{
onlyAlpha(str1[i]);
countWord++;
}
}
int main()
{
const int isize = 3;
string str1[] = {"!!HELLO","WHAT###", "%%left"};
string test = "haha";
const int size = 100;
string wordsminus[size];
int wordCount = 0;
const int alphabet = 26;
int freqcount[alphabet];
memset(freqcount, 0, 26*sizeof(int));
onlyAlpha(test);
cout << test << endl;
fillFrequency(test, freqcount, alphabet);
for(int j = 0; j < alphabet; j++)
{
cout << freqcount[j] << "\t";
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZTxpb21hbmlwPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8Y3N0cmluZz4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCi8vRnVuY3Rpb24gdG8gcmVtb3ZlIGdhcmJhZ2Ugb2ZmIHdvcmQKdm9pZCBvbmx5QWxwaGEoc3RyaW5nJiBzdHIxKQp7ICAgIAoJc3RyaW5nIG5ld1N0cjEgPSIiOwoJbmV3U3RyMS5yZXNlcnZlKHN0cjEuc2l6ZSgpKTsgCgoJZm9yKHN0cmluZzo6c2l6ZV90eXBlIGkgPSAwOyBpIDwgc3RyMS5zaXplKCk7IGkrKykKCXsJCgkJaWYgKCBpc2FscGhhKCBzdHIxW2ldICkgKSAKCQluZXdTdHIxLnB1c2hfYmFjayggc3RyMVtpXSApOwoJfQoJ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