NAME

inumber - request and return an integer value

SYNOPSIS

#include <stdio_p.h>

inumber (str, ival)
char *str;
int *inval;

DESCRIPTION

inumber writes the string pointed to by str onto the standard output device. This string can be a prompt requesting the user to type an integer value. If no prompt is desired str should be NULL. inumber reads a line from the standard input device, and looks for an optional string of tabs and spaces, then an optional sign, then a string of digits followed by tabs, spaces, or a newline. If it finds this pattern it converts it to an integer, returns the value in the address passed as ival, and returns 1. If the first digit in the string is 0, the string is interpreted in octal; otherwise, it is interpreted in decimal. If inumber encounters an end-of-file or a line consisting only of spaces, tabs, or a newline it returns 0. If it fings neither of these patterns it repeats the prompt and tries to recognize the next input line, continuing to do so until it finds a valid inuput string.

EXAMPLE

The following illustrates a call to inumber:
integer stat, sess;
if((stat = ("session number", &sess) == -1;
fprintf(stderr,"inumber error\n");
if((stat == 0)
sess = DEFAULT;
A possible interaction given the above is shown below:
session number: 2a
session number :2

SEE ALSO

atof(3P)

DIAGNOSTICS

If inumber cannot write the prompt string to standard output it prints an error message to standard error and returns -1.