In file input.h:

int get_number

(int* num, int msg, int min, int max, int err,
int def, int defval)

Get an integer within certain limits.

Documentation

Get an integer within certain limits.

Prompt msg asking for a number between min and max. Return the number in num. If def!=0, there is a default value (prompt def displays it) which is passed in defval. Prompts err if bad value entered.

Parameters:
num - pointer to an int. This is written to if a valid number is entered.
msg - is the short prompt number to display. This should give the user a brief idea of what is expected of them. This prompt should belong to the current message block. It will not be displayed if the value is zero, but please don't do this as it makes things look inelegant.
- min minimum allowed value for the number.
- max likewise, the maximum allowed value for the number.
err - the error prompt to display. Specify zero to disable error printing. You can have an optional %d format specifier in the error prompt. It will be substituted by the (wrong) number entered.
def - is the user prompt used when defaults are used (which must belong to the current prompt block). This is usually a short string added to the short menu prompt, and looks like `(Enter=%d)' or ` [%d]'. The format specifier gets the value of defval. Use a zero to disable printing of defval where, for instance, the default value is printed by msg.
defval - is the default value for when the user presses Enter.
Returns:
Zero if X entered; one is returned if the number was valid, in which case it is stored in num. A value of -1 implies that INF_HELP was set and the user entered `?'.

Alphabetic index



This page was generated with the help of DOC++.