Hello!
i'm new at programming, and I wanted to write a program that reads a text from standard input and outputs the frequency of each letter in the text, implying that A=a, that is to say, an A counts for an a. The other characters are identified as ''other''.
naturally, you know the number of characters of the text.
'A' up to 'Z' are in {65, .. , 90} and 'a' to 'z' are in {97, ... ,122}.
My idea was to convert the upper case letters into lower case letters.
I don't know how to put the text into an array, and how to convert...
please help me! =)
thanks a lot!
I only know the basic control statements of the c++ language, that is to say, ''for'' loops.
at first I input the number of characters, then the text (from the terminal), and then I want to put the text into an char array. But I don't know how to do that; i would look a bit like that :
#include <iostream>
int main (){
// text length
int len;
std::cout<< "length of text?";
std::cin >>len;
(and then i have to type the text in the terminal, and in a way put it into an array of char...) ; (the following part is not really correct, but maybe it lets you understand more what i mean)
//convert into lower case letters
char *A= new char [len];
for(int i=0;i<len;++i)
{std::cin>>A[i]; if ( A[i]<=90||A[i]>=65) A[i]+=32;}
I'm sorry! There's nothing wrong with it!
I just asked because in class we used to always use especially basic commands, so we don't know any other particular commands. We only know some basic control statements : if, else, while, for... and we are working on the arrays now. So we use really basic commands, that are sometimes more complicated to use than other short commands.
So I was just interested in how you can do it ''basically'', because, well, that is maybe more theoretical.
It's like when in maths you calcute limits with basic very complicated definitions, and afterwards you use formulas.
Anyway, thank you a lot for your help! =)