Chinaunix首页 | 论坛 | 博客
  • 博客访问: 302782
  • 博文数量: 79
  • 博客积分: 3458
  • 博客等级: 中校
  • 技术积分: 921
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-25 17:09
个人简介

自、管

文章分类

全部博文(79)

文章存档

2013年(7)

2012年(20)

2011年(18)

2010年(34)

分类: LINUX

2010-08-09 18:09:54

书上所给的例子太复杂我
我认为没有必要
不就是返回当前工作目录的绝对录进吗
我用getcwd()完成了
好像是取巧了 没办法 我现在只会这么写
char * getcwd(char *buf,int size)
getcwd函数将返回的绝对路径名放在buf所指的数组中
并返回buf      size要比路径名长度至少大1

#include
#include
#include
#include
int main(int argc, char *argv[])
{
char *cwd;
char buf[PATH_MAX+1];

if((cwd=getcwd(buf,PATH_MAX+1))==NULL)
{
    perror("getwd");
    exit(1);
}

puts(cwd);


return 0;

return EXIT_SUCCESS;
}
阅读(596) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~