Definitely a case for reading up on find_first_of, find_last_not_of .. and
the other 'find's; if you know you can go straight to yyyy from the first
occurence of '{' and use the same marker to begin parsing your 'zzzzz',
aaaaa, etc.'s, then just work out the most efficient way of doing so using
the STL find functions.
If you know the order of these strings, then an istream tokenizer would be a
good bet.
"Adam Balgach" <ffld@hotmail.com> wrote in message
news:a5c8620f.0411241317.59949169@posting.google.c om...[color=blue]
> Hello hello,
>
> i am trying to parse up a line that is in the format:
>
> @xxxxx yyyyyy {zzzzz, aaaaaa, bbbbbb}
>
> where there could be any number of elements inbetween the { ... }
>
> i am only concerned with getting the yyyyy and then the tokens in the
> { }
>
> so the code im using is:
> in->getline(line, 1024); //to get the inital line.
> char *name;
> name = strtok(line, " ");
> int count=0;
> char *firstThing;
> while(name!=NULL) {
> name = strtok(NULL, " {,}";
> if (count==0) {
> //do somehting with yyyyyy
> cout << "First Thing: "<<name<<endl;
> firstThing=name;
> }
> else if (count>0) {
> cout << "{"<<firstThing<<", "<<name<<"}\n";
> //do something with name (should = zzzzzzz then aaaaaaa hten
> bbbbbbb)
> }
> count++;
> }
>
> now when i run this code it outputs:
> First Thing: yyyyyy
> {yyyyyy,zzzzzz}
> {yyyyyy,aaaaaa}
> {yyyyyy,bbbbb}
> {yyyyyy,
>
>
> any idea why its running through this loop one too many times... ie
> the last entry shouldnt be htere?
> cheers,
> Adam.[/color]
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com