0

I want to call opendir() with the argument of the directory the program is being run from. If possible it will be a platform independent way. I'm confused because the accepted answer to a similar question doesn't look to be platform independent. Other answers say use Boost but a reply to this question states initial_path() is deprecated. If it can't be done in a platform independent the target is Windows.

4

3 回答 3

1

initial_path()已弃用,但它current_path()在程序开始时有效地为您调用,然后在任何后续调用中返回该结果。因此,您需要做的就是current_path()在程序开始时调用并将其存储在某个地方。

于 2012-08-15T21:42:07.597 回答
1

这是跨平台的,并告诉您程序的当前工作目录。

char *getcwd(char *buf, size_t 大小);

这是一个 posix 函数,应该在 Linux、OsX 和 Windows 上支持。在这里阅读:

http://linux.die.net/man/3/getcwd

于 2012-08-15T21:34:26.693 回答
0

大致相同的问题是here

您还可以从这里获得帮助:Makefile 教程

您也可以使用这些命令

initial_path()
current_path()
于 2012-08-15T21:57:28.950 回答