[fpc-pascal] Problems with assigning pointers
nc-gaertnma at netcologne.de
Tue Apr 10 19:03:40 CEST 2012
On Tue, 10 Apr 2012 18:08:04 +0200
dhkblaszyk at zeelandnet.nl wrote:
> I have some issues when assigning a pointer to a pointer variable.
> Consider this:
> TVertex = record
> x: double;
> y: double;
> PVertex = ^TVertex;
> TEdge = record
> v1: PVertex;
> v2: PVertex;
> I have assigned a value to a vertex variable. In my code I have an
> array of TEdge. When I try to assign a vertex to the edge element in the
> array the x value suddenly is changed to 3e-308 (or something similar).
> I don't understand why, perhaps someone could help me to figure this
> out.The code I'm using to assign the value is shown below. To my
> knowledge assigning a pointer this way is perfectly legal not?
> procedure add_edge(v1, v2: PVertex);
> SetLength(edge_list, edge_count);
> edge_list[edge_count - 1].v1 := v1;
Code looks ok. The bug is probably in the code you didn't send. Maybe
your vertices are on the stack?
More information about the fpc-pascal