Variable definitions | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Variable definitions

Atleast it used to be like this: int i; for (i... Since when is this okay? for (int i... Thanks :)

22nd Mar 2020, 9:08 AM
Daniel
Daniel - avatar
2 Answers
+ 6
The former was used in C89, the first C standard, as it was the only possible way in old C because variables had to be declared at the top of the block. The latter one was introduced in I believe C99, a little over 20 years ago, so, a pretty long time already. :)
22nd Mar 2020, 9:27 AM
Dennis
Dennis - avatar
+ 2
Gotcha, thanks. I'm old ;D
22nd Mar 2020, 9:29 AM
Daniel
Daniel - avatar