#include <string>
#include <iostream>
#include <cstddef>
#include <memory>
#include <utility>

std::unique_ptr<int[]> count_char(const std::string& s)
{
	// consider 128 ASCII decimal and their coresponding character codes
	std::unique_ptr<int[]> charASCIIArray = std::unique_ptr<int[]>(new int[128]{0});
	for (const auto& it : s)
	{
		if (('A' <= it && it <= 'Z') ||     // if char between (A,B,....,Z) or
			('a' <= it && it <= 'z'))       //         between (a,b,....,z)
			charASCIIArray[static_cast<int>(it)]++; // we count each corresponding array then
	}
	return std::move(charASCIIArray);
}

int main()
{
	std::string userinput = "random words WITH *- aLl";

	std::unique_ptr<int[]> charASCIIArray = count_char(userinput);
	for (std::size_t index = 0; index < 128; ++index)
		if (charASCIIArray[index] != 0)
			std::cout << "Letter " << static_cast<char>(index)  // convert back to char
			<< " occured " << charASCIIArray[index] << " times.\n";

	return 0;
}
