<分区>
package main
import "fmt"
func main() {
var inStr string
var inStr2 string
fmt.Printf("Input? ")
fmt.Scanf("%s", &inStr)
fmt.Printf("\nOutput: %s\n", inStr)
fmt.Printf("Input2? ")
fmt.Scanf("%s", &inStr2)
fmt.Printf("\nOutput: %s\n", inStr2)
}
这是输出
Input? 2
Output: 2
Input2?
Output:
Success: process exited with code 0.
如您所见,它不允许我输入 input2;它退出程序。