StrTok

I've been reading about parsing lately and messing around with StrTok but it gives me problems when performing simple actions.

Like if I did something like (after all the appropriate set up and what not)
1
2
std::cout << token[0] << "\n";
std::cout << token[1] << "\n";


The second token would never appear nor any other tokens if I looped through.

If i looped through this code: std::cout << token[0] << "\n";
The first token for each line would appear just fine. I looked a little farther and it seems people "hate" strtok?

I was wondering if anybody knew of a decent tutorial on parsing or some ideas for efficiently getting info from a getline() split into multiple strings for comparison.

I got some basic ideas that could use vectors but they don't seem that efficient.

I know I'm fishing for info here, I'm tired though so I'll see if i can't post some broken code tomorrow. Been struggling to make these tokens do what I want for a while now and need a break.
About strtok()
http://www.cplusplus.com/faq/sequences/strings/strtok/

Splitting strings
http://www.cplusplus.com/faq/sequences/strings/split/

The principles are the same no matter what the source sequence is.
Hope this helps.
Thank you, that "split a string" article is exactly what I was looking for.
Topic archived. No new replies allowed.