#include #include #include int main() { char path[200]; if (getcwd(path, sizeof(path)) == NULL) { perror("getcwd"); exit(EXIT_FAILURE); } printf("cwd = %s\n", path); if (chdir("/tmp") < 0) { perror("chdir"); exit(EXIT_FAILURE); } printf("chdir to /tmp succeeded\n"); if (getcwd(path, sizeof(path)) == NULL) { perror("getcwd"); exit(EXIT_FAILURE); } printf("cwd = %s\n", path); // fflush(NULL); system("ls"); exit(EXIT_SUCCESS); }