Converting C “FOR” loop to Delphi

后端 未结 1 1834
攒了一身酷
攒了一身酷 2021-01-22 15:48

I\'m trying to convert a FOR loop from C to Delphi, but I\'m with some doubts:

I know this code in C:

       for (i = 0; i < mb->s         


        
相关标签:
1条回答
  • 2021-01-22 15:57

    You cannot use a for in delphi to do this because the variable used to iterate cannot be modified.

    So this code

    for (i = 0; i < mb->size; i+= mb->data_size)
    

    can be written using a while

      i:=0;
      while (i<mb.size) do
      begin
       // do something
       Inc(i, mb.data_size);
      end;
    
    0 讨论(0)
提交回复
热议问题