11. Go - Input Bufio
BUFIO METHOD
import "bufio"
import "os"
scanner := bufio.NewScanner(os.Stdin)
scanner.Scan()
variable := scanner.Text()
fmt.Println(variable)
FMT METHOD
var name string
var age int
fmt.Scanln(&name, &age)
fmt.println(name,age)
// this method doesnt count white spaces
Increasing line buffer read size limit:
const maxCapacity = 512 * 1024 // max capacity
buf := make([]byte, maxCapacity) // buffer
scanner.Buffer(buf, maxCapacity) // put before scanning
Comments
Post a Comment