Thread: Using .txt files

  1. #1
    Registered User
    Join Date
    Aug 2009

    Using .txt files

    I understand how to open text files, and how to close them. But not use the bit inside so to speak.

    Can any one give me a quick run down on how to edit code inside, and use an if statement to check if a string is equal to any of the data within the text file.

  2. #2
    Registered User
    Join Date
    Sep 2004
    You need to read some tutorials. I would start here.
    bit∙hub [bit-huhb] n. A source and destination for information.

  3. #3
    Registered User CrissyCrisCris's Avatar
    Join Date
    Aug 2009
    I'm not 100% sure if I remember this correctly... but here goes:

    fstream FileIn;
    FileIn("Text.txt");  //Something like that
    char szLine[MAX_PATH];
    for (int i = 0; !FileIn.eof(); i++)
         FileIn.getline(szLine, MAX_PATH);
         /*I think I forgot something in here.  This is now you get a line of text from a text file*/
         if (strcmp(szLine, "Compare Text To") == 0)
              MessageBox(NULL, "Line Matches", "MessageBox", MB_OK);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reading .dat files from a folder in current directory...
    By porsche911nfs in forum C++ Programming
    Replies: 7
    Last Post: 04-04-2009, 09:52 PM
  2. Replies: 11
    Last Post: 11-26-2008, 11:43 PM
  3. Working with muliple source files
    By Swarvy in forum C++ Programming
    Replies: 1
    Last Post: 10-02-2008, 08:36 AM
  4. Folding@Home Cboard team?
    By jverkoey in forum A Brief History of
    Replies: 398
    Last Post: 10-11-2005, 08:44 AM
  5. Batch file programming
    By year2038bug in forum Tech Board
    Replies: 10
    Last Post: 09-05-2005, 03:30 PM