CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Cfile::Read

  1. #1
    Join Date
    Feb 2004
    Posts
    8

    Cfile::Read

    I have a text file, like a data file, such as;

    Text file:
    This is the test.

    I can easily write something like that into the text file. But the problem starts while reading. I cannot control the read parameter, I want to reach character values of this text like "T", "h", "i" and I want to seperate them to control more efficiently. What do you suggest for this situation?

  2. #2
    Join Date
    Jan 2002
    Location
    TamilNadu, India
    Posts
    158
    I am not sure if I have understood u correctly. But still, why don't you try reading into a buffer first and then try doing what u want??
    Muthu

  3. #3
    Join Date
    Feb 2004
    Posts
    8

    Unhappy

    What do you mean while saying "buffer"? It must be about handle a file CreateFile ReadFile?

    I'm so sorry, but I'm so new at programming with Visual C++, I want to only read the file. Give me a trick to read a file only... it maybe some lines...

    HANDLE hFile;

    hFile = CreateFile("c:\\trial.txt",
    GENERIC_READ,
    0,
    NULL,
    OPEN_EXISTING,
    FILE_ATTRIBUTE_NORMAL,
    NULL);

    if (hFile == INVALID_HANDLE_VALUE)
    {
    ErrorHandler("Could not open trial.ini"); // process error
    }

    This is true for the beginning while read a file? And What can I do after this? Give me a small lines or example about that

  4. #4
    Join Date
    May 1999
    Location
    Southern California
    Posts
    12,266
    In my CStdioFile Sample is sample code for reading from a file and writing to another file. If your file is a text file, then it is easier to use CStdioFile. Then you can use ReadString() to read each line into a CString. Using the data in the CString, you can process the text the same as any other CString.
    "Signature":
    My web site is Simple Samples.
    C# Corner Editor

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured