Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Difference between "while (…) continue;" and "while (…);"?

In The Linux Programming Interface, in some parts (for example section 26.3.1) the following code is written

while (waitpid(-1, NULL, WNOHANG) > 0)
    continue;

What is the difference between the above code and the following?

while (waitpid(-1, NULL, WNOHANG) > 0);

I think the second is better, but the mentioned book is a reference book so I have this question.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I looked in two books (The Linux Programming inTerface, Advanced programming in UNIX environment) and also I searched google.

>Solution :

The continue in your first example exists to make it a more readable loop and serves no functional purpose. The ; alone can be easily missed. Likewise for {}

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading