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
sort.Search GuessingGame documentation example does not work #43612
Comments
Sorry, the "What did you do>" question seemed to be unanswered. Answer is: Copied and ran the GuessingGame example from the sort.Search documentation. |
I tried this and it works fine as is, without the newline. We need more information. |
The example also work for me on Linux, but... #23562: Scanf works differently on Windows and Linux, and OP is using Windows. Possible root cause? The example was written and never tested on Windows? |
Here's the output when I run the code as it appears in the documentation:
Pick an integer from 0 to 100.
Is your number <= 50? y
Is your number <= 25? Is your number <= 12?
I double checked that my source code is properly formatted with Unix line
endings.
When I run it with the \n fix I noted, it works as expected.
I can't try it on Linux -- no easy access to a Linux box.
Could you guys try it on Windows? That should put it to bed quickly. If it
fails the same as it does for me, it's probably a Scan bug. If not, well,
this is not of any consequence to me. Just letting you know of the behavior
I'm seeing...
…On Sun, Jan 10, 2021 at 11:52 AM Alberto Donizetti ***@***.***> wrote:
The example also work for me on Linux, but... #23562: Scanf works
differently on Windows and Linux
<#23562>, and OP is using Windows.
Possible root cause? The example was written and never tested on Windows?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#43612 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABLA2AISTKNHDXXHCB3OC53SZIARXANCNFSM4V324NXQ>
.
|
I can confirm the issue is reproducible on Windows (using cmd). So yeah I think #23562 is indeed the root cause. |
Closing as a dup of #23562. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
What did you expect to see?
Expected to play the game.
What did you see instead?
Console prompting for an answer to its question asked 2 questions on same prompt line, making the game unusable.
Found and seemed to fix the problem in the example code: changed the fmt.Scanf("%s", &s) to fmt.Scanf("%s\n", &s).
The text was updated successfully, but these errors were encountered: