preset counter variable in a for loop --> 'has no effect' Error

Namal sotis22 at mail.ru
Fri Feb 28 08:48:37 UTC 2020


Hello,

I don't understand why this simple code causes a compiler error..

import std.stdio;

void main(){

  int b = 0;

  for (b; b<3; b++){
    writeln(b);		
  }
}

$Error: b has no effect

Same works perfectly fine in C++

#include <iostream>

int main(){
  int i = 0;

  for(i; i<3; i++)
    std::cout<<i<<'\n';
}

Please help me find what I am doing wrong. Thx


More information about the Digitalmars-d-learn mailing list