Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Borland C++ 2.x ( with Turbo C ) - <b>peek() examine word at memory location (macro)</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 peek()                  Examine Word At Memory Location (Macro)

 #include   <dos.h>

 int        peek(segment,offset);
 unsigned   segment;                     Segment
 unsigned   offset;                      Offset

    peek() examines a word at the memory address specified by
    'segment':'offset'.  peek() is treated as a macro if the header file
    <dos.h> is included. If the file is not included, or if #undef is
    used on it, peek() is a function.

       Returns:     A word--the value stored at the location specified by
                    'segment:offset'.

   Portability:     Unique to 8086 family of processors.

   -------------------------------- Example ---------------------------------

    The following statements use peek() to look at the contents of the
    third element in an array.

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

           int a[8] = {10,20,30,40,50,60,70,80};

           main()
               {
               int x;

               x = peek(FP_SEG((int far *) a), FP_OFF(a) + 2*sizeof(int));
               printf("x=%d\n", x);
               }


See Also: peekb() poke() pokeb()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson