Only a minor observation that, since C99 you can declare variables in any point in the function, not only at the top. You can even declare the variable inside the for clause
True, but old habits die hard.
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.