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

Reply

Join Date: Oct 2005
Posts: 20
Reputation: Savage221 is an unknown quantity at this point 
Solved Threads: 0
Savage221 Savage221 is offline Offline
Newbie Poster

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

 
0
  #1
Nov 5th, 2006
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.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 89
Reputation: TylerSBreton is an unknown quantity at this point 
Solved Threads: 3
TylerSBreton's Avatar
TylerSBreton TylerSBreton is offline Offline
Junior Poster in Training

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

 
0
  #2
Nov 5th, 2006
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.
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 3,114
Reputation: WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of 
Solved Threads: 281
Moderator
WaltP's Avatar
WaltP WaltP is offline Offline
Posting Sensei

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

 
0
  #3
Nov 6th, 2006
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.
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC