I tried
for (int i = 0, double j = 0.0f; i <= 30; i++, j++)
but it didn’t like that. It said ” ‘j’ undeclared “. It worked if both were ints. Is there not a way to declare it in the for loop?
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.
You can only use a single statement in the loop initializer. So you’ll have to declare at least one of your vars outside the loop:
If it worked with two ints you probably used
for (int i = 0, j = 0; ...)which is valid since only one statement (which declares multiple variables) is used.