I have to do my homework but I can not take path in C.For example ;
int main(void) {
char *path;
path = getenv("PATH");
if(path)
printf("The current path is: %s\n", path);
return 0;
}
If I run this code , I got "Segmentation fault (core dumped)". My os is Ubuntu 14.04 LTS.
Add
to the top of the listing and give that a try. It might be an assumed int return for getenv to char * pointer tripping up the code.