Thread: Problem searching for a string in a text file. Help?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Seven years? civix's Avatar
    Join Date
    Jul 2002
    Posts
    605

    Problem searching for a string in a text file. Help?

    Alright, I've been searching and digging through threads for a couple of hours now, and haven't really found anything I can use/understand.

    Code:
    ifstream choice_one_op_in ( "C:\\Program Files (x86)\\Electronic Arts\\Crytek\\Crysis\\Game\\Config\\diff_easy.cfg");
          string token; 
          string line = "g_godMode = 1";
          while(!choice_one_op_in.eof())
          {
              getline(choice_one_op_in,token);
    
              if (token.find(line, 0))
                  {
    	        cout << "The program found the word: " << line << endl; 
                   } 
          }
    The idea is that the program searches through a configuration file looking for the string. If it's found, it needs to return an error message.

    Can anyone explain to me what I'm doing wrong?

    Thanks in advance.
    Last edited by civix; 11-03-2010 at 03:34 AM. Reason: Loop closing bracket, indentation.
    .

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 04-25-2008, 02:45 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. A bunch of Linker Errors...
    By Junior89 in forum Windows Programming
    Replies: 4
    Last Post: 01-06-2006, 02:59 PM
  4. Calculator + LinkedList
    By maro009 in forum C++ Programming
    Replies: 20
    Last Post: 05-17-2005, 12:56 PM
  5. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM