In C/C++ Language… are for loops internally compiled as while loops?
In C/C++ Language… are for loops internally compiled as while loops?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, usually, basically. A for loop, written
can be rewritten as
Note that this doesn’t take into account scoping and such issues, because when you translate a for to a while, scoping can’t be written precisely in C++ syntax.
However, underneath, a for loop is really a series of statements and (conditional) gotos:
except that all of it is in assembly code.