Using .txt files

This is a discussion on Using .txt files within the C++ Programming forums, part of the General Programming Boards category; I understand how to open text files, and how to close them. But not use the bit inside so to ...

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    31

    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
    Location
    California
    Posts
    3,258
    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
    Posts
    13
    I'm not 100% sure if I remember this correctly... but here goes:

    Code:
    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, 10: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, 09:36 AM
  4. Folding@Home Cboard team?
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 398
    Last Post: 10-11-2005, 09:44 AM
  5. Batch file programming
    By year2038bug in forum Tech Board
    Replies: 10
    Last Post: 09-05-2005, 04:30 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21