改变当前的工作目录ç [英] Change current working directory C

查看:95
本文介绍了改变当前的工作目录ç的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找出一个办法,我可以使用C ++ code改变我的电流输出目录 - 也需要一个方法是平台无关。

I'm trying to figure out a way where I can change my current output directory using C++ code - and also need that method to be platform agnostic.

我找到了direct.h头文件是Windows兼容,这是UNIX / POSIX兼容的unistd.h中。任何解决方案?

I found the direct.h header file which is Windows compatible, and the unistd.h which is UNIX/POSIX compatible. Any solutions?

干杯。

推荐答案

CHDIR 函数可以使用了POSIX(的联机帮助)和Windows(被称为 _chdir 存在,但一个别名 CHDIR 存在)。

The chdir function works on both POSIX (manpage) and Windows (called _chdir there but an alias chdir exists).

这两种实现上的错误返回成功零和-1。正如你可以在手册页看到,更显尊贵errno值是POSIX变种可能的,但不应该真正发挥作用。

Both implementations return zero on success and -1 on error. As you can see in the manpage, more distinguished errno values are possible in the POSIX variant, but that shouldn't really make a difference.

这篇关于改变当前的工作目录ç的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆