Skip to content

Instantly share code, notes, and snippets.

@irondoge
Last active July 8, 2016 18:55
Show Gist options
  • Select an option

  • Save irondoge/13284d634ebfd5eb0e21a9c66db7eb87 to your computer and use it in GitHub Desktop.

Select an option

Save irondoge/13284d634ebfd5eb0e21a9c66db7eb87 to your computer and use it in GitHub Desktop.
get a pointer to the environment variables from any function [compilation: gcc -W -Wall -Wextra -std=c89 environ.c]
#include <stdio.h>
int main(int ac, char **av, char **env)
{
extern char **environ;
(void)ac;
(void)av;
printf("%p = %p | => %s\n", environ, env, environ[0]);
return (0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment