Creating structs

Simen Haugen simen at norstat.no
Fri Feb 2 03:53:32 PST 2007


I thought that if I create a struct in a loop, a new struct would be created each time, but if you see below, it's the same object. How can I create a new struct each iteration?

import std.stdio;

struct Test
{}

void main()
{
	for (int i=0;i < 2; i++)
	{
		Test t;
		writefln("Pointer: ", cast(int)&t);
	}
}



More information about the Digitalmars-d-learn mailing list