CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2009
    Location
    Genova - Italy
    Posts
    38

    Question find a string in a memory mapped txt

    Hi to all

    I have a txt file, which contains many strings like the followings:
    KEY1 STRING1
    KEY2 STRING2
    ......

    I have to search for the KEY* value and I have to copy the corresponding STRING* value.
    I mapped it into memory with CreateFile, CreateFileMapping and MapViewOfFile.
    Actually I read a single row of the mapped file and search for value KEY* inside of it: if the match results positive, I copy STRING* value. Otherwise I continue in my research.

    Is this the best way I have? There is something better? Something like function "fseek" which could work in memory mapped file?

    Thank you so much

  2. #2
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,656

    Re: find a string in a memory mapped txt

    Quote Originally Posted by motobizio View Post
    ...Is this the best way I have?
    Not sure what is the “best” here, but I would try strstr().
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinWindows - replacement windows manager for Visual Studio, and more...

  3. #3
    Join Date
    Jul 2009
    Location
    Genova - Italy
    Posts
    38

    Re: find a string in a memory mapped txt

    Thank you for your answer!
    This function results very useful!
    I will try to use it!

    Thank you again

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