Listing 5 A print-screen program

/* pscreen.c:                        *
 * Print the screen via video memory */

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

#define NROWS 25
#define NCOLS 80
#define NCHARS (NROWS * NCOLS)

main()
{
   unsigned far *vptr = MK_FP(0,0x463);
   char far *p;
   int count;

   /* Determine video memory address */
   if (*vptr == 0x3b4)
      p = MK_FP(0xb000,0);
   else
      p = MK_FP(0xb800,0);

   for (count = 0; count < NCHARS;
       ++count, ++p)
   {
      putc(*p++,stdprn);
      if ((count + 1) % NCOLS == 0)
          putc('\n',stdprn);
   };
   return 0;
}

/* End of File */