fork(3) download
  1. #include <stdio.h>
  2.  
  3. int main(int argc, char **argv, char** envp)
  4. {
  5. int i;
  6. char *s = *envp;
  7. for (i = 1; s; i++) //This loop starts from i=1 (as the 1st argument stores the file name itself),
  8. {
  9. printf("%s\n", s); //and goes until s becomes NULL (as the envp array is terminated by NULL)
  10. s = *(envp + i); // To increment the index of s pointer
  11. }
  12. return 0;
  13. }
Success #stdin #stdout 0s 2168KB
stdin
Standard input is empty
stdout
TMPDIR=/tmp/rlv5hO
PATH=/usr/local/bin:/usr/bin:/bin
PWD=/home/7gF1cp
LANG=en_US.UTF-8
SHLVL=0
HOME=/home/7gF1cp