Issue 19820 - Add readfln to std.stdio
Summary: Add readfln to std.stdio
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P4 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-04-23 20:35 UTC by Andre
Modified: 2024-12-01 16:34 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Andre 2019-04-23 20:35:59 UTC
It is quite hard to use readf for beginners as explained here by Ali and Adam.
https://forum.dlang.org/post/agspmmtjrthzxefjbwej@forum.dlang.org

Quote from Ali:
> The solution is to use readln, which regrettably comes too late in the book:

Quote from Adam:
> For "%s" with a string argument, it reads ALL of stdin into that string.
> This means you need to send an end-of-file indicator to the program. ctrl+z
> on Windows does this, and ctrl+d can on Linux (you might have to hit it 
> twice there; it doesn't technically send end of file, but can be read as it 
> by the program if there is no other input pending in the buffer).

> This is quite bizarre for new users, I agree, but it isn't technically 
> invalid.

> (my personal feeling though is readf is just a pile of confusion and should > almost never be used. I hate that it is introduced so early in most 
> tutorials... I'd rather have it in an appendix for special cases only rather
>  than like page 3.)

I would suggest to add a function readfln which solves the issue of readf.
readfln executes readln, strip #10 #13 and then executes formattedRead

Signature of readfln should be similair to readf
https://dlang.org/phobos/std_stdio.html#.readf
Comment 1 dlangBugzillaToGithub 2024-12-01 16:34:56 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/phobos/issues/10370

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB