Menu

Help with file parser

2002-09-25
2012-09-26
  • Nobody/Anonymous

    Hi! I found a text file on the internet with 10000 words in it.  I wanted to create a spell checker with it, but it has a lot of garbage.  Example:
    pillow     28    piercing

    Is there some sort of built in function that I can use to parse every , [space], and number out of the file?  I don't need an entire program or anything, just a couple of lines to get me going.

     
    • Nobody/Anonymous

      You could probobly use a standard for loop to eat out the block characters and spaces, but unless my copy of the c/c++ programmers reference is grossly incomplete there isn't a built in function to do such a thing. Search around google for "fstream loops text editing" and you should probobly find a nice long example.

      Zero Valintine

       
    • Nobody/Anonymous

      Thanks. One more question.  How do I get the total number of characters in the file for the for loop?

       
    • Matt Fiedler

      Matt Fiedler - 2002-09-26

      You probably don't want to use a for loop.  You should probably use a while loop as follows:

      while (!myFile.eof())
      {
      <various processing>
      }

      Hope this helps.

       
    • Nobody/Anonymous

       
    • Nobody/Anonymous

      The class CString in Microcrap VC++ does have a bulit in parser.  But I also believe old 'c' does as well.  Talk to Kip he knows about standard 'c' more than I do.  I have put some source on my ftp site:  ftp://66.222.198.62 in the Source Folder.  The file is converter.cpp and can be modified to do what you want it to.  For my reference, I would appreciate a upload of the updated code if you decide to use it (don't feel that you have to though).  I have also done a word wrap for c++ as well and it is also in there.

      Curtis

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.