Last active
June 28, 2018 13:58
-
-
Save higedice/f78ce4e5de4a12d4cc8c2210e9c50fca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
int main() | |
{ | |
char path[1024]; | |
printf("getenv(\"PWD\"): %s\n", getenv("PWD")); // " /home/me" | |
printf("cd /\n"); | |
chdir("/"); | |
printf("getenv(\"PWD\"): %s\n", getenv("PWD")); // "/home/me" | |
printf("getcwd(): %s\n", getcwd(path, sizeof((path)))); // "/" | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment