Could you tell me why I entered two scan, execute code can only let me enter a value
CodePudding user response:
You this input screen capture is not the same as your program?
Also is the outcome of the program execution is not capture images, which capture images is another piece of code, so can not see the problem of this code, you want to stick a piece of code
CodePudding user response:
reference 1st floor qybao response: you this input screen capture is not the same as your program? Also is the outcome of the program execution is not capture images, which capture images is another piece of code, so can not see the problem of this code, you want to put another piece of code post Bosses, I have already solved, is scanln directly to scan the code is ok, so in the end at the bottom, each student number and name can be entered, just want to pass the complete code, but found that the post can't upload pictures, now I wonder is why scan can and not a scanln, good strange CodePudding user response:
Look at the doc, should be no problem, if you have a problem input Scan is the input space, or newline separator, scanln is a newline separator https://golang.org/pkg/fmt/#Scanln func Scan Func Scan (a... Interface {}) (n int, err error) Scan scans the text read from standard input, storing successive space - separated values into successive arguments. Newlines count as space. It returns the number of items successfully scanned. If that is less than the number of arguments, err will report according to. Func the Scanf Func the Scanf (the format string, a... Interface {}) (n int, err error) The Scanf scans the text read from standard input, storing successive space - separated values into successive arguments as determined by the format. It returns the number of items successfully scanned. If that is less than the number of arguments, err will report according to the Newlines in the input must match Newlines in the format. The one exception: the verb always % c scans on the rune in the input, even If It is a space (or TAB etc.) or newline. Func Scanln Func Scanln (a... Interface {}) (n int, err error) Scanln is similar to Scan, but stops scanning at a newline and after the final item there must be a newline or EOF. CodePudding user response:
May be my input is not standard, I think they really lose the liquid do not have what problem, thank you ~ CodePudding user response:
reference qybao reply: 3/f look at the doc, should be no problem, if you have a problem input Scan is the input space, or newline separator, scanln is a newline separator https://golang.org/pkg/fmt/#Scanln func Scan Func Scan (a... Interface {}) (n int, err error) Scan scans the text read from standard input, storing successive space - separated values into successive arguments. Newlines count as space. It returns the number of items successfully scanned. If that is less than the number of arguments, err will report according to. Func the Scanf Func the Scanf (the format string, a... Interface {}) (n int, err error) The Scanf scans the text read from standard input, storing successive space - separated values into successive arguments as determined by the format. It returns the number of items successfully scanned. If that is less than the number of arguments, err will report according to the Newlines in the input must match Newlines in the format. The one exception: the verb always % c scans on the rune in the input, even If It is a space (or TAB etc.) or newline. Func Scanln Func Scanln (a... Interface {}) (n int, err error) Scanln is similar to Scan, but stops scanning at a newline and after the final item there must be a newline or EOF. May be my input is not standard, I think they really lose the liquid do not have what problem, thank you ~ CodePudding user response:
It has to do with your system environment, you should be a Windows environment, Windows line contains two characters \ r \ n, there is no question of Scanln under Linux,