Borland C++ reference

peek

raw OCR

Returns the word at memory location specified by segmentioffset.

Defined in header <dos.h>

Syntax

#include <dos.h>
int peek(unsigned segment, unsigned offset);

Portability

DOSUNIXWindowsANSI CC++ only
■■

Remarks

peek returns the word at the memory location segment.offset.

If peek is called when dos.h has been included, it is treated as a macro that expands to inline code. If you don't include dos.h, or if you do include it and #undef peek, you'll get the function rather than the macro.

Return value

peek returns the word of data stored at the memory location segmentioffset.

See also

Example

#include <stdio.h>
#include <conio.h>
#include <dos.h>

int main (void)
{
   int value = 0;
   printfC'The current  status of your keyboard is:\n");
   value = peek(0x0040,  0x0017);
   if (value & 1)
      printf "Right shift  on\n");
   else
      printf "Right shift  off\n");
   if (value & 2)
      printf "Left shift  on\n");
   else
      printf "Left shift off\n");
   if (value & 4)
      printf "Control key on\n") ;
   else
      printf "Control key off\n") ;
   if (value & 8)
      printf "Alt key on\n") ;
   else
      printf("Alt key off\n");
   if (value & 16)
      printf("Scroll lock on\n") ;
   else
      printf("Scroll lock off\n");
   if (value & 32)
      printf("Num lock on\n") ;
   else
      printf("Num lock off\n") ;
   if (value & 64)
      printf("Caps lock on\n") ;
   else
      printf("Caps lock off\n") ; ■
   return 0;

Differences from modern implementations

Nothing recorded yet.

Modern references

These are search links, not yet checked by hand.