Variable declaration on "start value" of FOR loop - What C standards allow it? -


c language

on c standard following code compiles without error (c89, c99, c11)

for (int = 0; < 10; ++i) {      something...  } 

i understand c compilers won't accept version above , variable "i" must declare outside parentheses. so:

int i; (i = 0; < 10; ++i) {      something...  } 

this allowed since c99. c99 , c11 support it.

in c89, first clause of for statement can expression. in c99 , c11 can expression or declaration. 1 single declaration allowed (though can declare several variables).


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -