C   40

env

Guest on 1st June 2022 01:30:57 AM

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int
  5. main(int argc, char* argv[], char* envp[])
  6. {
  7.   int i;
  8.   int count;
  9.  
  10.   if (argc < 2) {
  11.     fprintf(stderr, "Usage: %s <count>\n", argv[0]);
  12.     exit(1);
  13.   }
  14.   count = atoi(argv[1]);
  15.  
  16.   for (i=0; i < count; i++) {
  17.     if (envp == 0) {
  18.       printf("env %d: nothing!\n", i);
  19.       exit(1);
  20.     }
  21.     else if (envp[i] == 0) {
  22.       printf("env %d: null!\n", i);
  23.       exit(1);
  24.     } else
  25.       printf("env %d: %s\n", i, envp[i]);
  26.   }
  27. }

Raw Paste


Login or Register to edit or fork this paste. It's free.