<p>Sorry for the newb question.  I'm still learning programming.  So I'm using C++, and I need to do something like this:</p>

<pre><code>int n;
do {
    n = get_data();
    if(n != -1)
        send(n);
} while(n != -1);
</code></pre>

<p>This is just a sketch.  Anyway it doesn't feel real elegant.  I have to have my test twice.  I could just test once and set a flag, but that doesn't feel real elegant either since I have to check the flag twice.  It just seems like there should be a way to do this more easily, since it's so easy what I want to do.</p>

Howabout using
break
:
```
```
int n;
while(1) {
    n = get_data();
    if(n == -1)
        break;
    send(n);
}
```
```
This way you only test once, and quit immediately if get_data doesn't return what you want.