下面是我的简单代码,每当我试图在终端上输入角色'crack‘时,有时它接受得很好,有时它奇怪地认为它是'Drack’。它到底为什么要这么做呢?它经常发生
fmt.Println("\n Do you want crack a hash (type 'crack') or just help other nodes in cracking their hash (type 'help')?")
fmt.Scanf("%s\n", &role)
fmt.Println("role taken is", role)
if role == "crack" {

发布于 2017-04-28 13:47:41
这可能是因为您在scanf函数中使用\n,而不是在scanf中使用\n,请尝试在后续Println语句中使用它,如下所示:
fmt.Scanf("%s", &role)
fmt.Println("\nrole taken is", role)https://stackoverflow.com/questions/43672764
复制相似问题