I want to do something analogous to this C code.
c = getchar()
if (isdigit(c)) {
ungetc(c, stdin);
scanf("%d", &num);
}
In fmt package, fmt.Scanf("%d", &num) exists but ungetc doesn't exist. For
bufio package, Peek function exists which is great but there is no ReadInt.
Is there an elegant solution that i can use for this situation? Otherwise i
will read byte by byte as long as i have a digit and convert it to integer
once i'm done.
The input i am trying to tokenize is something like,
(32 + 5) * 2 - 5 / (41 - 7)
Thanks.
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.