Thread: String Iterators

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    110

    String Iterators

    Am in need of some help with a string iterator.

    Basically I want to set the iterator to a particular location of a string, such as that returned by the string::find() function.

    Any help would be greately apreciated.

    Later,
    WebmasterMattD
    WebmasterMattD.NET

  2. #2
    Registered User Casey's Avatar
    Join Date
    Jun 2003
    Posts
    47
    string::find() returns an interator, just do an assignment with the return value.

  3. #3
    Registered User
    Join Date
    May 2003
    Posts
    148
    >>string::find() returns an interator,
    No,string::find returns string::size_type.

    You can do this
    Code:
    string::size_type st = str.find("...");
    string::iterator strIter = str.begin();
    strIter += st;

  4. #4
    Registered User Casey's Avatar
    Join Date
    Jun 2003
    Posts
    47
    You're right, I was thinking of the generic find from <algorithm>.

  5. #5
    Registered User
    Join Date
    Apr 2002
    Posts
    110
    Thanks for that.

    incrementing the iterator by the number of possitions relative to the start worked.

    Later,
    WebmasterMattD
    WebmasterMattD.NET

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 04-25-2008, 02:45 PM
  2. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  3. Something is wrong with this menu...
    By DarkViper in forum Windows Programming
    Replies: 2
    Last Post: 12-14-2002, 11:06 PM
  4. Classes inheretance problem...
    By NANO in forum C++ Programming
    Replies: 12
    Last Post: 12-09-2002, 03:23 PM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM