for ( int iIdx = 0; iIdx < argc; ++iIdx )
_tprintf( TEXT( "Arg %d: %s\n" ), iIdx, argv[ iIdx ] );
_tprintf( TEXT( "\n" ) );
Is this valid in C? Because I get an error when I try to compile it, if I remove the int from the initializer section of the for loop, it compiles fine…
It is not valid in C before C99.
In C89/90 and earlier, declarations need to be at the start of each block. You can’t interleave declarations and normal code.
A declaration inside the
fordoes not count as being at the start of a block.