[help]why the output of getenv differ from environ?

When login as root, I make a project in qde, then run a simple program using getenv like this:
[color=blue]
#include <stdio.h>
#include <stdlib.h>

int main(int argc,char **argv)
{
char *path;
path=getenv(“PATH”);
if(path!=NULL)
printf(“PATH=%s\n”,path);
path=getenv(“PHOTON”);
if(path!=NULL)
printf(“PHOTON=%s\n”,path);
return EXIT_SUCCESS;
}

The program outputs:[color=red]
PATH=/sbin:/usr/sbin:/bin:/usr/bin
while command env outputs:[color=green]

PATH=/sbin:/usr/sbin:/proc/boot:/bin:/usr/bin:/usr/local/bin:/usr/local/sbin:
/opt/bin:/usr/photon/bin:/usr/photon/appbuilder:/opt/X11R6/bin:/usr/X11R6/bin
PHOTON=/dev/photon

Then I recompile this program like this:[color=red]
qcc pgm.c -V gcc_ntox86 -o pgm -g

and the program run normally and get everthing as same as env outputs.
Why getenv can’t get the value of global environ under qde just because that the qde use a different Makefile? Thanks a lot!

I don’t see why a QDE compiled and command line qcc compiled program would behavior differently.

If you RUN the program within qde, you may have a different environment. That may explain why your PATH looks different. I guess if you run the QDE compiled executable in a pterm, you will get the “right” output.

Thanks for your help. qde has a different environment from terminal environment, that’s true.