add envp pointer from main code
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
# exemples pour le chapitre sur le C
|
||||
# new Sat Feb 11 12:06:34 CET 2023
|
||||
|
||||
all: no-op slowprint fgets-simple packtest
|
||||
all: no-op slowprint fgets-simple packtest use_envp
|
||||
|
||||
no-op: no-op.c Makefile
|
||||
gcc -Wall $< -o $@
|
||||
@@ -19,3 +19,8 @@ demo-strtok: demo-strtok.c Makefile
|
||||
# added Wed Mar 27 10:01:41 UTC 2024
|
||||
packtest: packtest.c
|
||||
gcc -Wall $< -o $@
|
||||
|
||||
# added Thu Aug 8 13:44:58 UTC 2024
|
||||
use_envp: use_envp.c Makefile
|
||||
gcc -Wall $< -o $@
|
||||
|
||||
|
||||
16
code/C/use_envp.c
Normal file
16
code/C/use_envp.c
Normal file
@@ -0,0 +1,16 @@
|
||||
/* using envp for fun and profit */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char *argv[], char *envp[])
|
||||
{
|
||||
char *cptr;
|
||||
int idx = 0;
|
||||
cptr = envp[idx];
|
||||
while ( NULL != (cptr=envp[idx]) ) {
|
||||
fprintf(stderr, "envp[%d] %p --> %s\n",
|
||||
idx, cptr, cptr);
|
||||
idx++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user