Hello, for the final part of my program I need to count how many letters appear throughout a pretty large input file. Opening the file, storing to an array, etc.. is all taken care of. I'm clueless on how to count each letter that occurs. I've read structures are the way to go, and others that arrays are best. I know I'd need to declare an array along the lines of:

char letters[26] = "abcdefghijklmnopqrstuvwxyz";

but I'm clueless from here, thanks in advance for any help, tips and/or suggestions.

Recommended Answers

All 2 Replies

An array of characters is a string, and therefore checking the various methods available for strings in c would probably be a good start. Google strlen and see if that's any help.

Each character (letter, number, punctuation) has a numeric value. That value can be used as an index into an array of counters which you can increment for each character you read.

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.