954,496 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

extracting words frm a text file

Hi Guys ,

If I have a file compouse by words one per line how can I get all the words to put them together and have them separated only by one space. Also how can I make sure I'm extracting only words and not numbers or special character. I thanks.



EPA
(Environmental
Protection
Agency)
and
the
New
York
Water
Pollution
Control
Association
for
outstanding
achievement
and
operation
of
this
important

facility

hariza
Light Poster
38 posts since Sep 2006
Reputation Points: 31
Solved Threads: 0
 

something like this: note, we are not going to write the program for you.

open the file
do this until end-of-file is reached
    use extraction operator >> to read a word
    check each character  and remove any non-alphabetic characters
          (hint:  isalpha() macro will help you do make that check)
    add the word to a std::string object
end of while loop
Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You