GETINT

Section: C Library Functions (3)
Updated: 10/23/82
Index Return to Main Contents
 

NAME

getint, getlong, getshort - ask user to type an integer value  

SYNOPSIS

#include <stdio.h>
#include <ctype.h>

int getint (prompt,min,max,defalt);
char *prompt;
int min,max,defalt;

long getlong (prompt,min,max,defalt);
char *prompt;
long min,max,defalt;

short getshort (prompt,min,max,defalt);
char *prompt;
short min,max,defalt;
 

DESCRIPTION

Getint, getlong, and getshort ask the user to type in an integer.

They begin by printing the string prompt as a message to the user. The user then types in a number. If the number is valid and is within the range min to max, then it is returned as the value of getint (getlong, getshort). If it is invalid or is out of range, then an error message is printed and the prompt-and-response cycle is repeated. If the user types just a carriage return, then the value defalt is assumed.

Getint, getlong, and getshort are identical, except for the type of the parameters and the results.  

SEE ALSO

getbool(3), getstr(3), gethex(3), getstab(3), getdouble(3), etc.
intarg(3), longarg(3), shortarg(3)


 

Index

NAME
SYNOPSIS
DESCRIPTION
SEE ALSO

This document was created by man2html, using the manual pages.
Time: 12:50:16 GMT, May 26, 2025