Thread: Reading a word

  1. #1
    Registered User
    Join Date
    Aug 2006

    Reading a word

    I have this simple problem that I can't figure out. I'm trying scan in a text doc. and look for particular words. What would be the best way? I've tried using
    and put it in a loop but it only grabs a character at a time. I've also tried
    that stops at the white space and ends the program.

  2. #2
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Same questions over and over again. Please do a search for reading from a file on these boards. There's also inumerous FAQs on the matter. Both on Cprog website as everywhere else in the web.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  3. #3
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    whole line - getline();
    get - a character
    << a word, stops at a whitespace (space, tab, newline).

    There's some stringstream thing, I think, which does the whole file. Search search search!

  4. #4
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    You'll probably need a loop of some kind too.

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell

    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ:

    My website:
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reading Microsoft Word documents
    By Mavix in forum C# Programming
    Replies: 8
    Last Post: 08-04-2007, 07:39 AM
  2. please help with binary tree, urgent.
    By slickestting in forum C Programming
    Replies: 2
    Last Post: 07-22-2007, 07:55 PM
  3. reading file word by word
    By 98holb in forum C Programming
    Replies: 2
    Last Post: 01-25-2006, 05:49 PM
  4. Reading in a file word by word
    By Bumblebee11 in forum C Programming
    Replies: 4
    Last Post: 06-10-2003, 09:39 PM