Thread: Searching for specific string using fstream

  1. #1
    I Write C++ Apps, Sue Me.
    Join Date
    Feb 2006
    In My Computer

    Question Searching for specific string using fstream

    i haven't posted in a while (I've been a little busy). But I am writing a small console phonebook. What I want to know is, how do I search a text file for a specific string of text using fstream. In the case of my application, searching the file for a specific last name.

    Is there any function which I can use to do this?


  2. #2
    Registered User
    Join Date
    Jan 2005
    It depends on how the file is laid out, but basically you have to read the file into a string and search the string.

    If you have a bunch of records, you could read each record into a container, then sort the container by last name and find your record that way.

  3. #3
    Registered User
    Join Date
    May 2006
    You can use boost iostreams filters.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compile Error that i dont understand
    By bobthebullet990 in forum C++ Programming
    Replies: 5
    Last Post: 05-05-2006, 09:19 AM
  2. Need help on String Searching.
    By RP319 in forum C++ Programming
    Replies: 3
    Last Post: 11-21-2005, 10:33 PM
  3. Visual C++ 2005 linking and file sizes
    By Rune Hunter in forum C++ Programming
    Replies: 2
    Last Post: 11-12-2005, 10:41 PM
  4. Linked List Help
    By CJ7Mudrover in forum C Programming
    Replies: 9
    Last Post: 03-10-2004, 10:33 PM