I came across this code
for(; tail < len;tail++){
str[tail] = 0;
Why is there a “;” right after the “for(“?
When I took it out, it came up with a couple errors.
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.
It means that there is no initialization (it has already been done on previous lines).
In general a for loop has the following syntax:
All three expressions (initialization, termination and increment) are optional, but the semi-colons must be present. The code you have is equivalent to the following while loop:
It is also common to see for loops where all three expressions are missing:
This is an infinite loop and equivalent to this: