| | |
How to count/keep track of letters from file input in C?
![]() |
•
•
Join Date: Oct 2005
Posts: 20
Reputation:
Solved Threads: 0
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.
char letters[26] = "abcdefghijklmnopqrstuvwxyz";
but I'm clueless from here, thanks in advance for any help, tips and/or suggestions.
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
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
![]() |
Similar Threads
- problem with freeing memory (C)
- Doesn't open for file input successfully.... why? (C++)
- file input problems (with windows?) (Java)
- Reading file input into an array (C++)
- Storing file input to an array? (C)
- file input don't know where to start (C++)
- File input. (C++)
- vc++ mfc-i can't make getline work with a string for file input (C++)
Other Threads in the C Forum
- Previous Thread: Help making an Output File look presentable
- Next Thread: string-structure
| Thread Tools | Search this Thread |
* ansi api array arrays bash binarysearch calculate centimeter changingto char character convert copyanyfile copypdffile createcopyoffile createprocess() csyntax directory dynamic fflush file floatingpointvalidation fork forloop frequency function getlasterror getlogicaldrivestrin givemetehcodez graphics gtkgcurlcompiling gtkwinlinux hardware highest histogram homework i/o ide inches initialization intmain() iso km license linked linkedlist linux linuxsegmentationfault list logical_drives looping loopinsideloop. lowest match matrix microsoft motherboard mqqueue mysql oddnumber odf open opendocumentformat openwebfoundation pdf pointer pointers posix power program programming pyramidusingturboccodes read recursion recv recvblocked repetition reversing scanf scheduling segmentationfault send shape single socketprogramming stack standard strchr string suggestions test unix urboc user variable whythiscodecausesegmentationfault win32api windows.h windowsapi






