Name
inp, inpw - Read a byte or a word.
Syntax
#include <conio.h>
int inp(port)
unsigned inpw(port)
unsigned port;
Description
The inp and inpw functions read a byte and a word,
respectively, from the specified input port. The input value
can be any unsigned integer in the range 0 - 65,535.
Both inp and inpw are supported in OS/2 protected mode. If
you use these functions, you must also use a .DEF file to
declare the IOSEG segment that the run-time library uses to
perform input/output on the port. In addition, the intrinsic
(-Oi) versions of these functions do not work unless you put
the code in a segment that is marked with the IOPL keyword
in the .DEF file.
Return Value
The functions return the byte or word read from port. There
is no error return.
See Also
outp(DOS), outpw(DOS)
Example
#include <conio.h> #include <stdio.h>
/* Read will be done on port #0: */
unsigned int port = 0; char result;
main()
{
/* Input a byte from the port: */
result = inp(port);
printf("The value from port #%d is %d\n", port,
result);
}
This program reads a character from input port 0.
(printed 6/18/89)