Advertisement
stream13

Using argv, envp and apple variables

Mar 19th, 2016
1,767
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdint.h>
  3.  
  4. void print_nultstr(const char* envstr[], const char* envstr_name){
  5.     uint32_t i;
  6.     const char* tstr;
  7.  
  8.     if(envstr == NULL || envstr_name == NULL){
  9.         return;
  10.     }
  11.     i = 0;
  12.     tstr = envstr[0]; // Might be unsafe
  13.     do{
  14.         printf("%s[%d]: %s\n", envstr_name, i, tstr);
  15.         ++i;
  16.         tstr = envstr[i];
  17.     }while(tstr != NULL);
  18. }
  19.  
  20. int main(int argc, const char * argv[], const char* envp[], const char* apple[]) {
  21.     print_nultstr(argv, "argv");
  22.     print_nultstr(envp, "envp");
  23.     print_nultstr(apple, "apple");
  24.  
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement