Use fgets or scanf. Your user will have to specify the form in those cases where the input is ambiguous (e.g. 12345 might be octal, decimal, or hexadecimal, all of which have different values for that set of digits).