man pwd
命令查看man -k dir | grep 2
命令查看有哪些跟pwd相关的系统调用参数:DIR * dir。结构dirent定义如下:
struct dirent{
ino_t d_ino;//此目录进入点的inode
off_t d_off;//目录文件开头至此目录进入点的位移
unsigned short int d_reclen;//记录的长度
unsigned char d_type;//文件类型
char d_name[256];
};
定义数组buf[MAXPATH];
调用getcwd(buf, MAXPATH);
输出返回值;
#include <stdio.h>
#include <unistd.h>
#define MAXPATH 50
int main()
{
char path[MAXPATH];
puts(getcwd(path, MAXPATH));
return 0;
}
原文:http://www.cnblogs.com/dky20155212/p/7862211.html