```
const result = "Polar radius =%.02f θ=%.02f° →Cartesian x = %.02f y =%.02f\n"
func interact(questions chan polar, answers chan cartesian) {
reader := bufio.NewReader(os.Stdin)
fmt.Println(prompt)
for{
fmt.Println("Radius and angle:")
line, err:= reader.ReadString('\n')
if err != nil{
break
}
var radius,θ float64
if _,err:= fmt.Sscan(line, "%f %f ",&radius,&θ); err != nil {
fmt.Println(os.Stderr, "invalid input")
fmt.Println("err=",err)
continue
}
questions <-polar{radius,θ}
coord := <-answers
fmt.Println(result, radius,θ,coord.x,coord.y )
}
fmt.Println()
}
```
编译执行时,在如下代码报错:
var radius,θ float64
if _,err:= fmt.Sscan(line, "%f %f ",&radius,&θ); err != nil {
fmt.Println(os.Stderr, "invalid input")
fmt.Println("err=",err)
continue
}
错误信息:
```
&{0xc42000a3a0} invalid input
err= type not a pointer: string
Radius and angle:
```
请大神指点
更多评论
新手也需要好好提问:
1. 代码不完整;
2. 格式乱,markdown 基本语法得懂点,即使不懂,发布那里有教程,还提示了发布前预览下;
3. 节点也不好好选;
#2