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

  1. /* PARPAS.C: Parent 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. char string[25];
  14.  
  15. //*******************************************************************
  16. int main(void)
  17. {
  18.     unsigned segment, offset, length;
  19.     char temp[10], segoff[10];
  20.  
  21.     strcpy(string,"Parent wrote this");
  22.     printf("%s\n",string);
  23.  
  24.     // get the segment and offset of the current string
  25.     segment = FP_SEG(string);
  26.     offset = FP_OFF(string);
  27.  
  28.     // convert the segment to ascii
  29.     itoa(segment,temp,10);
  30.     length = strlen(temp);
  31.     segoff[0] = (char)(length + 48);
  32.     strcpy(&segoff[1],temp);
  33.  
  34.     // convert the offset to ascii
  35.     itoa(offset,temp,10);
  36.     strcpy(&segoff[length+1],temp);
  37.  
  38.     // spawn the child process with the converted ascii string
  39.     // as an argument
  40.     spawnl(P_WAIT,"chpass.exe","chpass.exe",segoff,NULL);
  41.     printf("%s\n",string);
  42.  
  43.     return 0;
  44. } // end of main()
  45.