FAQ
It is 'go version go1.0.3' on WindowXP and GoClipseV0.7.6
e.g.
```go
func main() {
for i := 0; i < 3; i++ {
var n,m int
var _, ok = fmt.*Scanf*("%d,%d", &n, &m)
if ok != nil {
fmt.Println(ok)
}
fmt.Println("input==>",n,",",m);
}
}
```go
The follow is on the console:
1,2
input==> 1 , 2
*unexpected newline*
input==> 0 , 0
2,3
input==> 2 , 3

please, can you tell me why i got 'unexpected newline'?

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Dmitry Vyukov at Mar 27, 2013 at 5:56 am
    Works fine on tip:

    $ go run /tmp/scanf.go
    1,4
    input==> 1 , 4
    5,6
    input==> 5 , 6
    3,5
    input==> 3 , 5


    On Wed, Mar 27, 2013 at 9:01 AM, wrote:
    It is 'go version go1.0.3' on WindowXP and GoClipseV0.7.6
    e.g.
    ```go
    func main() {
    for i := 0; i < 3; i++ {
    var n,m int
    var _, ok = fmt.Scanf("%d,%d", &n, &m)
    if ok != nil {
    fmt.Println(ok)
    }
    fmt.Println("input==>",n,",",m);
    }
    }
    ```go
    The follow is on the console:
    1,2
    input==> 1 , 2
    unexpected newline
    input==> 0 , 0
    2,3
    input==> 2 , 3

    please, can you tell me why i got 'unexpected newline'?

    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • peterGo at Mar 27, 2013 at 8:23 am
    To fix the problem on Windows (using \r\n for end-of-line?), revise the
    format to "%d,%d\n". For example,

    package main

    import "fmt"

    func main() {
    for i := 0; i < 3; i++ {
    var n, m int
    var _, ok = fmt.Scanf("%d,%d\n", &n, &m)
    if ok != nil {
    fmt.Println(ok)
    }
    fmt.Println("input==>", n, ",", m)
    }
    }

    Peter
    On Wednesday, March 27, 2013 1:01:54 AM UTC-4, lixi...@gmail.com wrote:

    It is 'go version go1.0.3' on WindowXP and GoClipseV0.7.6
    e.g.
    ```go
    func main() {
    for i := 0; i < 3; i++ {
    var n,m int
    var _, ok = fmt.*Scanf*("%d,%d", &n, &m)
    if ok != nil {
    fmt.Println(ok)
    }
    fmt.Println("input==>",n,",",m);
    }
    }
    ```go
    The follow is on the console:
    1,2
    input==> 1 , 2
    *unexpected newline*
    input==> 0 , 0
    2,3
    input==> 2 , 3

    please, can you tell me why i got 'unexpected newline'?
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • peterGo at Mar 27, 2013 at 8:29 am
    Dmitry,

    No, it doesn't.

    C:\>go version
    go version devel +2eb36d0ca449 Tue Mar 26 23:08:08 2013 -0700 windows/amd64

    The question said "on Windows."

    Peter
    On Wednesday, March 27, 2013 1:56:00 AM UTC-4, Dmitry Vyukov wrote:

    Works fine on tip:

    $ go run /tmp/scanf.go
    1,4
    input==> 1 , 4
    5,6
    input==> 5 , 6
    3,5
    input==> 3 , 5



    On Wed, Mar 27, 2013 at 9:01 AM, <lixi...@gmail.com <javascript:>>
    wrote:
    It is 'go version go1.0.3' on WindowXP and GoClipseV0.7.6
    e.g.
    ```go
    func main() {
    for i := 0; i < 3; i++ {
    var n,m int
    var _, ok = fmt.Scanf("%d,%d", &n, &m)
    if ok != nil {
    fmt.Println(ok)
    }
    fmt.Println("input==>",n,",",m);
    }
    }
    ```go
    The follow is on the console:
    1,2
    input==> 1 , 2
    unexpected newline
    input==> 0 , 0
    2,3
    input==> 2 , 3

    please, can you tell me why i got 'unexpected newline'?

    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts...@googlegroups.com <javascript:>.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Lixin3811 at Mar 27, 2013 at 1:09 pm
    Thanks for Dmitry.

    My environment is 'go version go1.0.3' on WindowXP and GoClipseV0.7.6. And your?


    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedMar 27, '13 at 5:41a
activeMar 27, '13 at 1:09p
posts5
users3
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase