> Is char **envp a parameter to describe the environment parameters? If
> so, how many char* are refered by this char**?
How can I get the length of the array char* envp[]? Would anyone give me
a piece of code to handle such operation?--retrieve the length of an
array with unknow length.
> Is char **envp a parameter to describe the environment parameters? If
> so, how many char* are refered by this char**?
Just iterate through the array until you find a NULL pointer.
> I want to know how to use the envp parameter. Can anyone give a short
> sample code?
#include <stdio.h>
int main(int argc, char* argv[], char* envp[])
{
while(*envp) puts(*envp++);
return 0;
}
BTW: if you're looking for a specific environment variable (rather than for
a list of them), you're better off with the getenv() function.
#include <stdio.h>
int main(int argc, char* argv[], char* envp[])
{
int n = 0;
while (envp[n] != NULL) {
printf("envp[%d]: <%s\n", n, envp[n]);
n++;
}
printf("Got %d environment variables\n", n);
return 0;
}
I hope this may be of some help.
"Sean Yang" <yan...@purdue.edu> wrote in message
news:3D4874E1...@purdue.edu...