How can I Input string more than 100000 characters

func main() {
sc := bufio.NewScanner(os.Stdin)
buf := make([]byte, 0, 10241024)
sc.Buffer(buf, 1024
1024)
sc.Split(bufio.ScanWords)
sc.Scan()
temp := sc.Text()
fmt.Println(len(temp))
}

I input string with length 100000 but this code returns 9998
Please help

That might be your operating system that flushes, try reading repeatedly until you got everything you want to have.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.