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
#include <stdlib.h>
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With