TetaTricks/code/voirenv.c

26 lines
451 B
C
Raw Normal View History

2022-09-12 01:39:21 +02:00
/*
* Low level acces to the environment space
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[], char *envp[])
{
char *ptr, *clone, *tok;
int foo = 0;
while ( NULL != (ptr=envp[foo]) ) {
printf("%4d %s\n", foo, ptr);
clone = strdup(ptr);
tok = strtok(clone, "=");
printf(" key : %s\n", tok);
tok = strtok(NULL, "=");
printf(" value : %s\n", tok);
free(clone);
foo++;
}
return 0;
}