Question

I 've written a program to form words with pointers and dynamic data structures

But it does not work and show an error at line 19 ( element is not declared in the type of pointer ) Help me please finish it. I will be grateful

program pointers;

type
  zv = ^pointer;

  pointer = record
    element : char;
    next : zv;
  end;

var
  vlan : zv;  {separate element}
  vslov : zv;  { pointer for word }
  symbol : char;

begin
  readln(symbol);
  new(vslov);

  vslov^.element := symbol;
  vslov^.next := nil;
  vlan := vslov;

  while symbol <> '.' do
    begin
      read(symbol);
      new(vlan^.next);
      vlan := vlan^.next;
      vlan^.element := symbol;
      vlan^.next := nil;
    end;
end.
Was it helpful?

Solution

pointer is a pre-defined type name. It is the type used to represent an untyped pointer. So zv is a pointer to a pointer. And the pre-defined type pointer is not a record and therefore cannot be used with the member access operator ..

Solve the problem by choosing a different name for your record type.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top