For starters, you should know that the strtok
function is pretty ancient as well. It's in the C89 standard, but probably existed in many implementations before that (for example in 4.3BSD which was released in 1986). In fact, the sscanf
function is probably newer than the strtok
function.
But if you have such an ancient compiler that, and actually don't have the strtok
function, and your input string doesn't follow the exact format you have in the question, but can be more free-form (and so can't really use the pattern-matching functionality of sscanf
) then you have to parse the string manually.
This manual parsing can actually be quite simple, just loop over the string until you find a digit, then collect all consecutive digits while constructing the number. Once you get a non-digit character, you have your number. Of course, this will only get the first number in the string.