- #include <unistd.h>
- #include <stdio.h>
- #define BUF_SIZE 40
- int main() {
- char buf[BUF_SIZE];
- char *curDir = getcwd(buf, BUF_SIZE);
- if (curDir)
- puts(curDir);
- return 0;
- }
- //该片段来自于http://www.codesnippet.cn/detail/281120137595.html
来源: http://www.codesnippet.cn/detail/281120137595.html