home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sftick.zip / beg / mem / good / mem.C < prev    next >
Text File  |  1994-04-21  |  831b  |  35 lines

  1. #define INCL_DOSMEMMGR
  2.  
  3. #include <os2.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6.  
  7. int main ( VOID )
  8. {
  9.    PBYTE          pbBuffer = 0;
  10.    APIRET         arReturn ;
  11.    USHORT         usIndex ;
  12.  
  13.    /* allocate some memory */
  14.    arReturn = DosAllocMem (( PPVOID ) &pbBuffer,
  15.                              10,                    /* BINGO */
  16.                                    /* don't forget to commit */
  17.                              PAG_READ | PAG_WRITE | PAG_COMMIT  ) ;
  18.  
  19.    /* if OK */
  20.    if ( arReturn == 0 ) {
  21.  
  22.         /* loop 0-10, writing to the allocated memory */
  23.       for ( usIndex = 0 ; usIndex < 10 ; usIndex++ ) {
  24.  
  25.           if (pbBuffer[usIndex])
  26.              pbBuffer [usIndex] = 1 ;
  27.           printf("\nusIndex = %d",usIndex ) ;
  28.  
  29.       } /* endfor */
  30.  
  31.    } /* endif */
  32.  
  33.    return 0 ;
  34. }
  35.