Counting charecter occurences in a file *Simple*

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pj1234678
    New Member
    • May 2012
    • 1

    Counting charecter occurences in a file *Simple*

    How can I count the occurences of each character in a text file and then organize them by most occuring?


    im a little new at this and i just joined so i kinda wanted an example
  • johny10151981
    Top Contributor
    • Jan 2010
    • 1059

    #2
    Simple trick is take an int array with the size 256
    say the name is count[256];

    read character by character say name is ch

    Code:
    while(ch=readcharsomehow(filename))
    {
     count[ch]++;
    }
    do sort by yourslef

    Comment

    Working...