'Read user input in The Go Playground
I made my first program in the Go language and I don't understand why when I use the Go platform: (https://go.dev/play/ ) the program doesn't wait for user input.
package main
import (
"fmt"
)
func main() {
var eleLen int
var givenNUM int
var TF bool
fmt.Println("Enter the length of array: ")
fmt.Scanln(&eleLen)
arr := make([]int, eleLen)
for i := 0; i < eleLen; i++ {
fmt.Scanln(&arr[i])
}
fmt.Println("Enter number: ")
fmt.Scanln(&givenNUM)
for i := 0; i < eleLen; i++ {
if arr[i] >= givenNUM {
continue
} else {
TF = false
}
}
fmt.Println(TF)
}
The output that I get is:
Enter the length of array:
Enter number:
false
Program exited.
I don't have the option to input the array and numbers.
Solution 1:[1]
The notes under the Playground editor at https://go.dev/play/ state:
The only communication a playground program has to the outside world is by writing to standard output and standard error.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | blackgreen |
