Thread: File I/O searching...

  1. #1
    Registered User
    Join Date
    Dec 2003

    File I/O searching...


    Im having trouble with file I/O.

    My problem is this, i have a file of formated data like this:
    KEY: 34
    djflkj jsdklfj asjdflkj adslkfjljlajo eoiwj jlifjlk dlksajlkmlkbn lkjdlkjoi oqiwjeoi kjd
    KEY: 34
    KEY: 35
    This is Plaintext... wow, its great for people to be able to read me ;)
    KEY: 35
    KEY: 36
    kjldflk alkjsfoi oijf oidsjfoim lkjvl kjaofijowieajfl lkjsfe
    KEY: 36
    Of course the example above is made up, but the format is the same. Basicly what i am trying to do is take files from a wordlist, store them to a string... then scan all the keys(usally from 1-1000) for common words to narrow the search down. What I dont understand is how i can print what KEY number the word is found it because of the randomness of the output... Any suggestions?

    PS. the program i am working on is simply a program to expirment brute forcing with the Beufort/Vinger ciphers, turning grilles, and other old crytograhic devices...

  2. #2
    Senior Member joshdick's Avatar
    Join Date
    Nov 2002
    Phildelphia, PA
    If you want a relationship to exist between key number and word (and both are unique), then I suggest using <map>. That's the STL's version of associative arrays. They let you do stuff like
    map<int, string> m;
    m["the answer"] = 42;
    But if the keys are sequential like in your example, then a vector of strings might suffice.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. gcc link external library
    By spank in forum C Programming
    Replies: 6
    Last Post: 08-08-2007, 03:44 PM
  2. Visual C++ 2005 linking and file sizes
    By Rune Hunter in forum C++ Programming
    Replies: 2
    Last Post: 11-12-2005, 10:41 PM
  3. File I/O problem
    By 81N4RY_DR460N in forum C++ Programming
    Replies: 12
    Last Post: 09-03-2005, 12:14 PM
  4. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  5. Searching txt files (another file i/o qn)
    By Catif in forum C++ Programming
    Replies: 9
    Last Post: 05-13-2002, 04:14 PM