Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add readfln to std.stdio #10370

Open
dlangBugzillaToGithub opened this issue Apr 23, 2019 · 0 comments
Open

Add readfln to std.stdio #10370

dlangBugzillaToGithub opened this issue Apr 23, 2019 · 0 comments

Comments

@dlangBugzillaToGithub
Copy link

andre reported this on 2019-04-23T20:35:59Z

Transfered from https://issues.dlang.org/show_bug.cgi?id=19820

Description

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
@LightBender LightBender removed the P4 label Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants