944,047 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 2043
  • C RSS
Nov 5th, 2006
0

How to count/keep track of letters from file input in C?

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Savage221 is offline Offline
20 posts
since Oct 2005
Nov 5th, 2006
0

Re: How to count/keep track of letters from file input in C?

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.
Reputation Points: 25
Solved Threads: 3
Junior Poster in Training
TylerSBreton is offline Offline
89 posts
since Oct 2006
Nov 6th, 2006
0

Re: How to count/keep track of letters from file input in C?

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.
Moderator
Reputation Points: 3278
Solved Threads: 894
Posting Sage
WaltP is offline Offline
7,747 posts
since May 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: Help making an Output File look presentable
Next Thread in C Forum Timeline: string-structure





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC