Why doesn't this piece of code work?

Ali Çehreli acehreli at yahoo.com
Sun May 15 17:37:00 UTC 2022


On 5/15/22 08:27, SvGaming wrote:

 > I am so confused right now. It works if that code is the main function.
 > But in the full program that is only one of the functions and is not the
 > main function.

Could it be that the main() function exits before calling that other 
function?

You can sprinkle simple writeln calls to figure out exactly where it 
goes wrong:

void main() {
   writeln("entered main");
   writeln("before calling foo");
   foo();
   writeln("exiting main");
}

Ali



More information about the Digitalmars-d-learn mailing list