Maybe this should check for sanity (i.e. greater than zero and less than some sane value, say 10). Consider using strtol instead of atoi. Storing the integer in a string is ugly anyway (but I don't have a better idea, either).