我试图让这段代码运行,但他跳过了功能登录
package main
import "fmt"
var name string
var password string
func getName() {
fmt.Print("What's your name : \n")
fmt.Scanf("%s", &name)
}
func showName() {
fmt.Print("Your name is " + name + "\n")
}
func getPassword() {
fmt.Print("What's your password : \n")
fmt.Scanf("%s \n", &password)
}
func singOrLog() {
var input string
input = ""
var loop bool
loop = false
for loop == false {
fmt.Print("Do you want to make an account or login (0 for register and 1 login) : ")
fmt.Scanf("%s \n", &input)
if input == "0" {
register()
loop = true
} else if input == "1" {
login()
loop = true
}
}
}
func login() {
var nameCorrect string
nameCorrect = name
for !(nameCorrect == name) {
fmt.Print("What's your name :\n")
fmt.Scanf("%s", &nameCorrect)
}
}
func register() {
getName()
showName()
getPassword()
login()
}
func main() {
singOrLog()
}
慕的地10843
相关分类