loop lopy wrote:
How does writeln knows its the end of a string? I have the following code:
String = packed array[1..256] of char;
var Test: String;
begin Test:='Hello world'; writeln (Test); Test[8] := Test[12]; writeln (Test); end.
The output is:
Hello world
Hello w rld
How does writeln knows where to stop printing the string?
It doesn't. "Writeln(something)" is specified as shorthand for "write(something); writeln".
However write knows that you specified the string to be an array of 256 chars, so it outputs 256 chars (unless told to truncate by a field specification). Those chars have somehow become blanks in your system, and that part is not standard. The assignment to test evidently has been arranged to append blanks, and it also appears as if the write operation has been arranged to elide trailing blanks, at least when the line is ended by the writeln operation. Strictly speaking the assignment to test should have raised an error.
The only function of a naked writeln is to terminate the current line.