title: Counting the number of occurrences of words in a textfile
body: <p>How could I go about keeping track of the number of times a word appears in a textfile? I would like to do this for every word.</p>
  
  <p>For example, if the input is something like:</p>
  
  <p>"the man said hi to the boy."</p>
  
  <p>Each of "man said hi to boy" would have an occurrence of 1.</p>
  
  <p>"the" would have an occurence of 2.</p>
  
  <p>I was thinking of keeping a dictionary with word/occurrence pairs but I'm not sure how to implement this in C. A link to any similar or related problems with a solution would be great.</p>
  
  <hr>
  
  <p>EDIT: To avoid rolling out my own hash table I decided to learn how to use glib. Along the way I found an excellent tutorial which walks through a similar problem. <a href="http://bo.majewski.name/bluear/gnu/GLib/ch03s03.html" rel="nofollow noreferrer">http://bo.majewski.name/bluear/gnu/GLib/ch03s03.html</a></p>
  
  <p>I am awestruck by the number of different approaches, and in particular the simplicity and elegance of the Ruby implementation.</p>