Liste des Groupes | Revenir à cl c |
bart <bc@freeuk.com> writes:On 15/04/2025 20:07, Scott Lurndal wrote:bart <bc@freeuk.com> writes:>On 15/04/2025 14:19, Kaz Kylheku wrote:Thats's fine. But it means a real 'for' loop doesn't exist in C;
you have to emulate it using that 3-way construct, which is naff,
and also error prone.
Real for loops _are_ a three-way construct.
135 FOR I=1 TO 10 STEP 2 [BASIC]
for(i = 1; i < 11; i += 2) [C/C++]
do 1 = 1, 10, 2 [FORTRAN]
Any step other than 1 is unusual. So Basic and Fortran would
typically be:
>
for i = 1 to 10 # 6 tokens; Basic
do i = 1, 10 # 6 tokens; Fortran
for i = 1, 10 # 6 tokens; Lua
for i to 10 do # 5 tokens; Mine (using default start)
to 10 do # 3 tokens; Mine (when index is not needed)
>
Let's look at that C again:
>
for (int i = 1; i < 11; i += 1) # 15 tokens; C
for(i = 1; i++ <= 10;)
Les messages affichés proviennent d'usenet.