How do i change the address of a New struct in a loop?!
Posted
by Yasin
on Stack Overflow
See other posts from Stack Overflow
or by Yasin
Published on 2010-05-16T11:40:05Z
Indexed on
2010/05/16
11:50 UTC
Read the original article
Hit count: 201
Hi guys, i'm writing a simple code which is about polynomials using link lists in C#. the problem i have is that whenever it creates a new struct (node) in the for loop it gives it the same address as the previous node was given. so how do i fix it ? here is my struct :
struct poly { public int coef; public int pow; public poly* link;} ;
and here is the where the problem occurs:
for (; i < this.textBox1.Text.Length; i++)
{
q = new poly();
......
p->link = &q;
}
&q remains unchanged !
© Stack Overflow or respective owner