home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / dtx9202 / borhot / parpas.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-01-07  |  1.4 KB  |  49 lines

  1. /* ------------------------------------------------------ */
  2. /*                     PARPAS.C                           */
  3. /*                  Parent Process                        */
  4. /*                                                        */
  5. /*  Must be compiled in a memory model which uses far     */
  6. /*  pointers by default, i.e., compact, large or huge.    */
  7. /* ------------------------------------------------------ */
  8. #include <process.h>
  9. #include <string.h>
  10. #include <stdlib.h>
  11. #include <stdio.h>
  12. #include <dos.h>
  13.  
  14. char string[25];
  15.  
  16. // ------------------------------------------------------- *
  17. int main(void)
  18. {
  19.   unsigned segment, offset, length;
  20.   char     temp[10], segoff[10];
  21.  
  22.   strcpy(string, "Parent wrote this");
  23.   printf("%s\n", string);
  24.  
  25.   // get the segment and offset of the current string
  26.   segment = FP_SEG(string);
  27.   offset = FP_OFF(string);
  28.  
  29.   // convert the segment to ascii
  30.   itoa(segment,temp,10);
  31.   length = strlen(temp);
  32.   segoff[0] = (char)(length + 48);
  33.   strcpy(&segoff[1],temp);
  34.  
  35.   // convert the offset to ascii
  36.   itoa(offset,temp,10);
  37.   strcpy(&segoff[length+1],temp);
  38.  
  39.   // spawn the child process with the converted ascii string
  40.   // as an argument
  41.   spawnl(P_WAIT, "chpass.exe", "chpass.exe", segoff, NULL);
  42.   printf("%s\n", string);
  43.  
  44.   return 0;
  45. } // end of main()
  46. /* ------------------------------------------------------ */
  47. /*                  Ende von PARPAS.C                     */
  48.  
  49.