A question on C programming and Outputing variables

I was wondering if someone could show me what I'd need to do in C programming language to output the current values of all of your environment variables and do so in such a way that it will duplicate an "env" command on unix. Does anyone know how and can you share it with me?

Thanks in advance.

you have the getenv function

or you can have your main as

int main(argc, argv, env)
int argc;
char *argv[];
char *env[];
{
int cnt;
for(cnt=0;env[cnt];cnt++)
printf("%s\n",env[cnt]);
return 0;
}

My gratitude to you. ^___^