Searching for specific string using fstream

This is a discussion on Searching for specific string using fstream within the C++ Programming forums, part of the General Programming Boards category; Hi, i haven't posted in a while (I've been a little busy). But I am writing a small console phonebook. ...

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

    Question Searching for specific string using fstream

    Hi,
    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?

    Thanks!

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    7,344
    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
    l2u
    l2u is offline
    Registered User
    Join Date
    May 2006
    Posts
    630
    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, 10: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

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