I have to write a code on c++(dev c++ actually) that counts the number of each letter,and give a percentage of using for each letter....But i don't know how put a txt during the execution,because the txt is asked to be more than 1000 words.

Recommended Answers

All 2 Replies

You should start to open and read a text file.Here is a tutorial if you don't know how to do that.

You could use something like this:

std::map<char,int> dict;
int c;
while((c = getchar())!=EOF) dict[c]++;
for(char& p : dict) std::cout << p.first << ": " << p.second << std::endl;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.