Hi all,

First post, so go easy on me!

Writing a very basic command line calculator in C at the mo. The user interface is as follows:

number <space> number <space> operator

So user can enter 2 (or more) numbers separated by a space and then the mathematical operator to use on them.

e.g "1 2 3 +" is the same as 1 + 2 + 3

My program works by reading in the first char and then determining whether it's a number or an operator (by seeing if the char is in the ASCII range for numbers 0-9).

If the char is a number, it calls a function to read in the whole number (may not just be a single digit, e.g. 34, 5.385...) by calling scanf() and using the %f conversion specifier to store a float (remember numbers are separated by whitespace, so this is ok).

BUT, here lies the problem, because I already used getchar() to get the first digit of the number, so when I use scanf() it misses off the first digit, and I cannot for the life of me find a suitable function in stdio.h that lets me move the file reader position back 1.

Sorry I've gone on for so long, but can anyone help me out? I'd greatly appreciate it!

Thanks,

James