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.T ext.Length; i++)
{
q = new poly();
......
p->link = &q;
}
//&q remains unchanged!
//p.s. the class is unsafe too
//edit, its C# but i have to make it look like C so i'm not allowed to use linked lists
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.T ext.Length; i++)
{
q = new poly();
......
p->link = &q;
}
//&q remains unchanged!
//p.s. the class is unsafe too
//edit, its C# but i have to make it look like C so i'm not allowed to use linked lists
Comment