Bardia Jedi
2013-02-04 15:09:24 UTC
Hi I'm trying to read an basic equation and output result! here my code
package main
import "fmt"
func main (){
fmt.Print("input ekvation: ")
var a, b int
var s rune
fmt.Scanf("%d %5v %d", &a, &s, &b)
fmt.Println (a, string(s), b)
}
the idea is that the user input an equation and the program separtas the
int and the operations and acts accordingly
e.g.
1+2
set 1 to int a
+ is a char (rune) so it stors it as rune
2 is an integer
so throw some logic is output 3
----------
now the problem is that scanf reads evrything after the %s!
anyideas?
package main
import "fmt"
func main (){
fmt.Print("input ekvation: ")
var a, b int
var s rune
fmt.Scanf("%d %5v %d", &a, &s, &b)
fmt.Println (a, string(s), b)
}
the idea is that the user input an equation and the program separtas the
int and the operations and acts accordingly
e.g.
1+2
set 1 to int a
+ is a char (rune) so it stors it as rune
2 is an integer
so throw some logic is output 3
----------
now the problem is that scanf reads evrything after the %s!
anyideas?
--
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-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
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-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.