3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by Nick Evan
0

This seems to me like it is just a delimiting problem...

That is, if each link is separated by "<", then u simply need to copy each character that occurs up until this...

Unless I am over-simplifying the problem, all I would do is just a tokenized approach: move through the file character by character. Then you just need to set up a few checks to make sure you are still reading a link (i.e. make sure the character is not a "<", and copy it. You can do this by creating a "PeekCharacter" function, i.e. by storing each character in some sort of buffer and then performing the test...). I would almost be inclined to set up a list structure to store the data...

Hopefully that helps...but I may have misinterpreted your problem..

0

move through the file character by character.

It would work, but it a bit too 'C' for my taste. How about using the getline() function with a third parameter as delimiter?

ifstream file("yourfile.txt");
if (file)
{
    std::string word;
    std::vector <std::string> array;
    while ( getline(file, word, '<'))
        array.push_back(word);
}

This doesn't account for spaces tabs and newlines off course, but it's a simple program that stores strings in a vector from a file delimited with a '<'

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.