There are several things which prevent me from running your C code. No #includes are given (though I can guess that stdio.h, stdlib.h and string.h are needed). You need to #define CBASE. And you don't seem to use argv[1] at all.
You should also put in a check that argc == 2, if that's what's needed, and exit gracefully if it isn't. You don't say how the program is called from the command line, i.e. what argv[1] and argv[2] are supposed to be. If you put these things right we may be able to help. It seems likely to be a classic out-by-one error! David
