Error "Unexpected '\n' when converting from type LockingTextReader to type int"

rikki cattermole rikki at
Wed Sep 7 23:31:29 UTC 2022

On 08/09/2022 11:24 AM, Synopsis wrote:
> On Wednesday, 7 September 2022 at 23:06:44 UTC, rikki cattermole wrote:
>> Text in buffer: "123\n"
>> Read: "123"
>> Text in buffer: "\n"
>> Read: exception, expecting number for "\n"
>> Changing your readf format specifier to include the new line should work.
> Thank you!
> Adding the \n seems to solve my problem: ```readf("%s\n", &f1.num)```
> I have two further questions about this!
> a- What is the difference with this syntax with the exclamation mark? 
> ```readf!"%s\n"(f1.num);```

That is a template.

It'll type check that the format specifier matches your arguments.

> b- Do I need to put ```/n``` in every readf statement? I mean, 
> considering that every input gets entered after pressing intro key (and 
> I guess this is what introduce the \n)


More information about the Digitalmars-d-learn mailing list