Just a sidenote, to show how hard this stuff actually is..

Your gettok() implementation is not proper C code, as you're returning a pointer (token) to a buffer (stri) in the stackframe of the function being exited (gettok itself). The next called function (eg. the overloaded << operator, or numtok) may overwrite this buffer, resulting in the "token" pointer pointing to undefined data. You would have to allocate memory for the token, require the parent function to provide a pointer to a buffer for it, or use a global buffer variable, instead.
--------------------
Saturn, QuakeNet staff, #help.script