home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / diverses / tctnt / chpass.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-27  |  1.0 KB  |  40 lines

  1. /* CHPASS.C: Child Process
  2.  
  3.     Must be compiled in a memory model which uses far pointers by
  4.     default, i.e., compact, large or huge.
  5. */
  6.  
  7. #include <process.h>
  8. #include <string.h>
  9. #include <stdlib.h>
  10. #include <stdio.h>
  11. #include <dos.h>
  12.  
  13. #pragma warn -par   // we know argc is never used!
  14. //*******************************************************************
  15. int main(int argc, char **argv)
  16. {
  17.     char *segment, *offset, *address;
  18.     unsigned seg, off, length;
  19.  
  20.     // extract the segment value from the string
  21.     segment = (char*) calloc(10,sizeof(unsigned));
  22.     length = (unsigned)(argv[1][0] - 48);
  23.     strcpy( segment, &argv[1][1]);
  24.     segment[length] = NULL;
  25.  
  26.     // extract the offset value from the string
  27.     offset = (char*) calloc(10,sizeof(unsigned));
  28.     strcpy(offset,&argv[1][length+1]);
  29.  
  30.     // convert from ascii to integer
  31.     seg = atoi(segment);
  32.     off = atoi(offset);
  33.  
  34.     // make pointer to parent data, and modify string
  35.     address = (char*) MK_FP(seg,off);
  36.     strcpy(address,"Child    modified");
  37.  
  38.     return 0;
  39. } // end of main()
  40.