linux的getcwd和readlink的区别
针对linux下的程序,有两个路径: 1>运行程序的路径; 2>可执行文件所在的路径
例如:

如果我在/home/yongchao下执行
$ ./temp/test 那么 运行程序的路径是:/home/yongchao 而可执行文件所在的路径是/home/yongchao/test

执行结果:

ps: 还有一个通过相对路径来寻找绝对路径的程序
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std; int main(int argc, char** argv)
{
char relative_path[] = "./";
char absolute_path[] = {};
if ( NULL == realpath(relative_path, absolute_path) )
{
cout<<"resolve path error"<<endl;
return ;
} cout<<"the absolute path : "<<absolute_path<<endl;
return ;
}
执行结果:

linux的getcwd和readlink的区别的更多相关文章
- Linux read/write fread/fwrite两者区别
Linux read/write fread/fwrite两者区别 1,fread是带缓冲的,read不带缓冲. 2,fopen是标准c里定义的,open是POSIX中定义的. 3,fread可以读一 ...
- Linux Kernel: buffers和cached的区别
The page cache caches pages of files to optimize file I/O. The buffer cache caches disk blocks to op ...
- Linux C -> symlink 和 readlink -> 符号链接
Linux C -> symlink 和 readlink -> 符号链接 -------------------------------------------------------- ...
- Linux执行shell脚本方式及区别&命令后台运行
Linux执行shell脚本方式及区别&命令后台运行 http://blog.csdn.net/heqiyu34/article/details/19089951/
- Windows Server服务器之Linux server与windows server的区别
Linux server与windows server的区别用linux做server,相对于windows server有什么优势? 首先,平均故障时间少,只要配置和使用得当,linux的平均故障( ...
- linux中 su 与 su - 的区别
linux中 su 与 su - 的区别 su只是切换了用户身份,shell环境仍然是切换前用户的shell环境 su -是用户和shell环境一起切换成. 备注:1.切换了shell环境会相应的用户 ...
- 网络工程师和Linux运维工程师有什么区别?学哪个比较好?
网络工程师和Linux运维工程师有什么区别?学哪个比较好? 机缘巧合下,我进入了一家从事vpn与系统集成的公司,很感谢公司能留下我这个非网络工程专业的毕业生,从对网络一窍不通,慢慢可以自己独立完成工作 ...
- linux系统——fread()与read()函数族区别
fread与read区别: 1,fread是带缓冲的,read不带缓冲. 2,fopen是标准c里定义的,open是POSIX中定义的. 3,fread可以读一个结构.read在linux/unix中 ...
- windows 环境和linux环境下 ping命令的区别:
Ping 是Windows自带的一个DOS命令.利用它可以检查网络是否能够连通,用好它可以很好地帮助我们分析判定网络故障.该命令可以加许多参数使用,键入Ping按回车即可看到详细说明.Ping 命令可 ...
随机推荐
- cmd 控制台 提示:请求的操作须要提升!
cmd 控制台 提示:请求的操作须要提升! 在windows7中想用route add 或相关route等命令须要以管理员身份执行,假设windows7以下没有以管理身份执行那么加入路由时候route ...
- [Angular 2] Create Angular 2 Porject with Angular CLI
Install: npm i -g angular-cli Create a project: ng new hello-angular2 Run the project: cd hello-angu ...
- [TypeScript] 0.First Example
Create a greeter.ts file: class Student { fullname : string; constructor(public firstname, public mi ...
- 赵雅智:js知识点汇总
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvemhhb3lhemhpMjEyOQ==/font/5a6L5L2T/fontsize/400/fill/I0 ...
- 解决Visual Studio 2010新建工程时出现『1>LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt』错误
VS2010在经历一些更新后,建立Win32 Console Project时会出"error LNK1123" 错误. 解决方案为: 第一步:将:项目|项目属性|配置属性|清 ...
- 关于IB_DESIGNABLE / IBInspectable的那些事
前言 IB_DESIGNABLE / IBInspectable 这两个关键字是在WWDC 2014年”What’s New in Interface Builder”这个Session里面,用Swi ...
- How to create a PPPoE Server on Ubuntu? (Untested)
How to create a PPPoE Server on Ubuntu? March 30, 2011 coder_commenter Leave a comment Go to comment ...
- C++ STL (备忘)
2014-08-04 16:33:57 (1) map map定义形式 map<type1,type2> map_name; map的基本操作函数: C++ Maps是一种关 ...
- C#泛型集合—Dictionary<K,V>使用技巧
转载:http://blog.csdn.net/a125138/article/details/7742022 1.要使用Dictionary集合,需要导入C#泛型命名空间 System.Collec ...
- react 资源汇总
前端变化虽快,但其实一直都围绕这几个概念在转: URL - 访问什么页面 Data - 显示什么信息 View - 页面长成什么样 Action - 对页面做了什么操作 API Server - Da ...