home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / diverses / tctnt / allocm1.c next >
Encoding:
C/C++ Source or Header  |  1991-08-27  |  665 b   |  26 lines

  1. /* ALLOCM1.C: shows conflict in memory allocation schemes
  2. */
  3.  
  4. #include <alloc.h>            // for farmalloc()
  5. #include <dos.h>                // for allocmem()
  6. #include <stdio.h>            // for printf()
  7.  
  8. //*******************************************************************
  9. main()
  10. {
  11. #pragma warn -aus                // ptr IS assigned a value that isn't used!
  12.     unsigned seg, count = 0;
  13.     char far *ptr;
  14.  
  15.   // allocates next available block
  16.     allocmem( 100, &seg );
  17.     printf(" Allocated block at %X:0000\n", seg);
  18.     while ((ptr = (char far*) farmalloc(50)) != NULL)
  19.     count++;
  20.  
  21.   // can't allocate!
  22.     printf(" Allocated %u 50 byte pieces\n", count);
  23.  
  24.   return 0;
  25. } // end of main()
  26.