提示多个用户输入失败[关闭]

package main

import "fmt"

func main() {  
    var inStr string  
    var inStr2 string  
    fmt.Printf("Input? ")  
    fmt.Scanf("%s", &inStr)  
    fmt.Printf("
Output: %s
", inStr)  
    fmt.Printf("Input2? ")  
    fmt.Scanf("%s", &inStr2)  
    fmt.Printf("
Output: %s
", inStr2)  
}

this is output

Input? 2
Output: 2  
Input2?   
Output:     
Success: process exited with code 0.  

As you can see, it does not allow me to enter input2; it exits the program.

These symptoms can occur on Windows, where lines may end with "" instead of "". Try adding an explicit newline ("") to the Scanf format. For example, "%s ",

package main

import "fmt"

func main() {
    var inStr string
    var inStr2 string
    fmt.Printf("Input? ")
    fmt.Scanf("%s
", &inStr)
    fmt.Printf("
Output: %s
", inStr)
    fmt.Printf("Input2? ")
    fmt.Scanf("%s
", &inStr2)
    fmt.Printf("
Output: %s
", inStr2)
} 

Output:

Input? 1

Output: 1
Input2? 2

Output: 2