Unfortunately scanf() and its friends can cause all kinds of problems and can present a security risk. For all but the simplest programs, a more reliable way is to get the input string into a buffer (making sure to avoid overflow) and then pick it apart with your own code.
Even if you use sscanf() to do this, at least you can do some basic checks on the input string before you go to work on it. For example, if you're expecting digits you can check for non-digit characters. David
