gpt4 book ai didi

c++ - 如何使用 Boost.Filesystem 更改当前路径

转载 作者:IT老高 更新时间:2023-10-28 22:36:35 25 4
gpt4 key购买 nike

启动程序时,我想使用 current_path() ("C:\workspace\projects") 打印当前路径。然后我希望能够更改路径,比如说“c:\program files”,所以当我再次打印 current_path() 时,我想打印“c:\program files”。像这样的

int main()
{
cout << current_path() << endl; // c:\workspace\projects
aFunctionToChangePath("c:\program files");
cout << current_path() << endl; // c:\program files
}

库中是否有我缺少的函数以便我可以完成它?

最佳答案

int main()
{
cout << current_path() << '\n'; // c:\workspace\projects
current_path("c:\\program files");
cout << current_path() << '\n'; // c:\program files
}

关于c++ - 如何使用 Boost.Filesystem 更改当前路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5677652/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com