There is a program consisting of a record of three integer variables. You need to enter the elements of the record from the keyboard and display the address of the second element and the address of the record on the monitor. tp swears at @s .c in the code below. Writes:

Cannot read variables of this type.

Where is the mistake?

TYPE structure = record a : integer; b : integer; c : integer; end; var S : structure; begin with S do begin writeln; write('Введите элемент записи a: '); read(a); write('Введите элемент записи b: '); read(b); write('Введите элемент записи c: '); read(c); end; writeln; write('Запись S состоит из: '); writeln; write('a = ', sa); writeln; write('b = ', sb); writeln; write('c = ', sc); writeln; write('Адрес второго элемента записи: ', @s .c); writeln; write('Адрес записи: ', @s ); end. 

    2 answers 2

    In Pascal, there is a more native method of taking the address of an entity (variable, function) - this is the function addr.

     writeln; write('Адрес второго элемента записи: ', ofs(sc)); writeln; write('Адрес записи: ', ofs(s)); 

    upd. you just need to ask correctly :) And you can also word( @s .c) but if the compiler is 16-bit, then you will still need to correctly select the address

    • This option also does not work. - user4703 1:01 pm

    Better to do type casting to longint:

      writeln; write('Адрес второго элемента записи: ', longint( @s .c)); writeln; write('Адрес записи: ', longint( @s ));