fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. int main (int argc, char *argv[])
  6. {
  7. char *ptr;
  8. if (argc < 3)
  9. {
  10. printf ("Usage: %s <env var> <target prog>\n", argv[0]);
  11. exit(0);
  12. }
  13. ptr = getenv (argv[1]);
  14. ptr += (strlen(argv[0]) - strlen(argv[2])) * 2;
  15. printf ("%s will be at %p\n", argv[1], ptr);
  16. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
Usage: ./prog <env var> <target prog>