You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The code:
package main
import (
"fmt"
)
func main() {
for i := 0; i < 2; i++ {
var name string
fmt.Print("Input Name:")
n, err := fmt.Scanf("%s", &name)
fmt.Println(n, err, name)
}
}
Build And Run.
Then, I input:golang,and enter,the result is:
Input Name:golang
1 <nil> golang
Input Name:0 unexpected newline
But on linux,the same code, the result is ok:
Input Name:golang
1 <nil> golang
Input Name:golang
1 <nil> golang
The reason is: on windows, The "enter" is "\r\n", but in fmt
package, it is only deal "\n".
The text was updated successfully, but these errors were encountered:
Hello one should either acknowledge that semantics are OS-dependendent or change
implementation (ASAP!) - I think damage is already done so leaves first option.
The root problem of course is that some OS-s do not have an opaque record structure
for files. (this includes Unix as well as Windows - still rather silly - once details
are visible they are bound to be different )
by xuxinhua1984:
The text was updated successfully, but these errors were encountered: