Hi friends, I have some confusions about how the ‘readln“ works.
This is an example:
program test;
var
first: string;
second: string;
begin
writeln('Please enter your first and second name:');
readln(first, second);
writeln('your first name is ', first, ' second name is ', second);
readln;
end.
when I inputted some string and entered 'return', the console would directly print the result though 'second' had not been assigned a value. 'second' just used the default value ''.
But if I change the program to this:
program test2;
var
first: string;
age: integer;
begin
writeln('Please enter your first name and age:');
readln(first, age);
writeln('your first name is ', first, ' and age is ', age);
readln;
end.
After I inputted some string and entered 'return', the console would wait for my next input for 'age' variable and then printed the correct result.
I wonder why the readln behaves differently when it receives two string variables. Also, I wonder where I can find the details of readln's implementation. I didn't find it in the FPC source directory.