linux C 获取当前的工作目录
2016-07-06 13:49
393 查看
#include <stdio.h> #include <string.h> #include <unistd.h> int main(void) { char buffer[1024] ; //获取当前的工作目录,注意:长度必须大于工作目录的长度加一 char *p = getcwd(buffer , 40); char *dir = NULL; printf("buffer:%s p:%s size:%d \n" , buffer , p , strlen(buffer)); //获取当前工作目录的名字 dir = (char *)get_current_dir_name(); printf("dir:%s \n" , dir); char *twd = NULL ; twd = getwd(buffer); printf("buffer:%s twd:%s \n" , buffer , twd); return 0 ; }运行结果:
buffer: p:(null) size:0
dir:/mnt/sdb1/yangyx/system系统编程/文件目录接口及声卡实现
buffer:/mnt/sdb1/yangyx/system系统编程/文件目录接口及声卡实现 twd:/mnt/sdb1/yangyx/system系统编程/文件目录接口及声卡实现
相关文章推荐
- linux C 获取当前的工作目录
- linux C 获取当前的工作目录
- linux 下 的 atom编辑器安装
- centos7 rc.local无效
- centos7 安装jdk1.7
- 一步一步学ROP之linux_x86篇
- 在Centos命令环境下,改变命令提示符颜色
- Centos7 下谷歌日志库GLog配置
- Linux之文件类型和权限的获取与操作
- CentOS 7 YUM 10分钟快速安装 LNMP 环境详细教程
- Linux下Socket服务器与客户端编程
- linux设备驱动程序中的阻塞、IO多路复用与异步通知机制
- LInux 安装 mysql2 gem失败
- linux 中的库
- Linux中变量$#,0,1,2,@,*,$,?的含义
- centos安装svn并配置钩子同步到www目录
- 每日一linux命令(25)-------linux文件属性详解
- 两台Linux系统之间传输文件
- linux-IBUS框架-中文输入法双拼问题
- centos安装gcc