In C if you have the following code:
for (size_t x, y = someValue; y > 0; y -= x, ptr1 += x, ptr2 += x)
{
// do stuff
}
Will the variable y also be of the type size_t or would it be an int?
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.
a declaration of
means that all of a,b,c are same type (int) as are x,y,z (size_t)
The declaration inside a for-loop is no different — and in your example both x and y are of type size_t
however in your example
xis not initialized (only y is set tosomevalue) — and unless the body of the loops set it to something you will find thaty -= xis going to give yourandomundefined results.