我試圖讓這段代碼運行,但他跳過了功能登錄package mainimport "fmt"var name stringvar password stringfunc 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()}
跳轉(zhuǎn)功能。
阿波羅的戰(zhàn)車
2023-04-10 10:43:01