Thread: Scanning a text file.

  1. #1

    Scanning a text file.

    I have a project I need to do in which I need to look at a file, scan it, and show any occurances of C++ operators or variables. Like finding how many times int is shown.

    The only help I'm looking for is could someone point me to, or show me, how I would scan a text file character by character and check it? There's a lot more to the project, but I can do that on my own. This is the part I'm stuck on.

    Thanks in advance.

  2. #2
    Also, how would I get a string input of word?

    I know how to compare it, but how would I get the input of it?

    Example is I find the word "dog" in the text file, and I want to compare it to a table or whatever of words, and match it with "dog" and mark an occurance of it. Basically like what a find function does.

  3. #3
    Well, after tinkering with it, I got it to scan and print out the text file just fine. But I'd still like to know how to scan words at a time rather than just comparing character by character.

    I'd like to know how to stop scanning after a return or space, put what I've scanned into a buffer, then compare. Is there a easier way to do this than just manually pounding out code?


  4. #4
    Registered User
    Join Date
    Nov 2001
    Continuing this line of thought........ is there any support available in C/C++ for regular expressions?

    "Technology has merely provided us with a more efficient means for going backwards" - Aldous Huxley

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 12:36 PM
  2. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 05:02 AM
  3. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. Outputting String arrays in windows
    By Xterria in forum Game Programming
    Replies: 11
    Last Post: 11-13-2001, 07:35 PM