Proposal of a general do-while loop
Manfred Nowak
svv1999 at hotmail.com
Tue Jul 17 10:43:48 PDT 2007
Taro Kawagishi wrote
> I think a more natural way to express the logic is to write the
> code as in listing 4.
>
> // listing 4
> size_t pos = 0;
> do {
> pos = text.find(pattern, pos);
> } while (pos != string::npos) {
> cout << "pattern found at " << pos << "\n";
> ++pos;
> }
>
Where is the problem with using `for'?
for( size_t pos= 0
; ( pos = text.find(pattern, pos), pos != text.length)
; pos++
)
{
writefln( "pattern found at %s", pos) ;
}
-manfred
More information about the Digitalmars-d
mailing list