StudyingUnixInterface/4/fileDirectory/chdir.c

16 lines
234 B
C
Raw Permalink Normal View History

2020-12-07 04:17:01 +00:00
#include <unistd.h>
2020-12-08 03:33:48 +00:00
#include <stdio.h>
2020-12-07 04:17:01 +00:00
int main(void) {
2020-12-08 03:33:48 +00:00
if(chdir("/home/eric") < 0) {
printf("chdir error\n");
return -1;
}
char buf[1024];
char *pbuf = getcwd(buf, 1024);
printf("CWD: %s\n", pbuf);
2020-12-07 04:17:01 +00:00
return 0;
}