How to read from standard input in the console?

后端 未结 11 1175
迷失自我
迷失自我 2020-11-28 00:54

I would like to read standard input from the command line, but my attempts have ended with the program exiting before I\'m prompted for input. I\'m looking for the equivalen

11条回答
  •  星月不相逢
    2020-11-28 01:35

    Can also be done like this:-

    package main
    import "fmt"     
    
    func main(){
        var myname string
    fmt.Scanf("%s", &myname)           
    fmt.Println("Hello", myname)       
    }
    

提交回复
热议问题