searching string...

Okay so here is my issue, i can't seem to figure out how to search a string i have stored in a linked list. I need to search the string for the '@' character and then move forward and backwards to the first ' ' to get emails out of files.
I know this is a beginner issue, but i have been farting around with the .find() and other parts of string.h Can anyone point me in the right direction, please.

EDIT:
I just came across some code and am working on something like this, am i going in the right direction?

for (int i = 0; i < aStudent->str.length(); i++)
{
if (aStudent->str.at(i) == '@')
{
while (aStudent->str.at(i) != ' ') i--; // moving back to beginning
while (aStudent->str.at(i) != ' ') // moving forward again to end
{
aStudent->email += aStudent->str.at(i);
i++;
}
} // if
} // for
Last edited on
maybe you could show some code here so that we can see what you have done instead of guessing about your linked list etc. ?
I edited the original post, if this isnt enough i can post the whole thing...
You know strings have member functions like .find() which allows you do this a lot quicker?
okay i see what i have been doing... i can use find() instead of the if statement and work from there.
You could use the at() method to locate the '@' and then pass that location and the beginning/end of the string to the substr() method to get the tokens.
Topic archived. No new replies allowed.