- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在编写一个程序来告诉我是否成功更改了我的目录。然而,这是行不通的。我经历了调试器模式,据我所知,该程序只是查看我的 Visual Studio 项目文件夹 c:\Users#'s\blablabla 中的文件 -----我想找到 dir1,它是我桌面上的一个文件夹(这个目录可以在任何地方)这是我的代码
#include <iostream>
#include <fstream>
#include <direct.h>
#include <io.h>
#include <cstring>
#include "functions.h"
using namespace std;
int main(int argc, char**argv)
{
int i = 1;
if (argc < 2)
{
cout << "no command line arguments given" << endl;
}
for (i = 1; i < argc; i++)
{
if (_chdir(argv[i]) == 0)
{
cout << "Program changed directories successfully" << endl;
}
else
cout << "Unable to change to the directory " << argv[i] << endl;
}
}
最佳答案
I want to find dir1 which is a folder on my desktop (and this dir could be anywhere)
_chdir
函数不会在您的整个计算机上搜索目录。它准确地更改为您指定的目录。如果您传递 c:\\dir1
,则它会尝试更改到目录 c:\\dir1
:根目录中的 dir1
目录你的 C: 驱动器。如果要搜索计算机上名为 dir1
的任何目录,您需要自己执行搜索。
关于c++ - _chdir() 不改变目录 C++,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26045152/
我正在编写一个程序来告诉我是否成功更改了我的目录。然而,这是行不通的。我经历了调试器模式,据我所知,该程序只是查看我的 Visual Studio 项目文件夹 c:\Users#'s\blablabl
在使用这些函数时,我遇到了错误。调试器在 _chdir(dirCorrente); 行上显示“damged heap”。 主要调用这些函数如下: - char* temp = getCartellaC
我应该选择一个而不是另一个有什么区别吗? 最佳答案 它们实现相同的结果但属于不同的 API,因此它们以不同的方式返回结果和报告错误。 如果您已经在使用任一 API 的其他例程,请选择那个。如果不是,则
我是一名优秀的程序员,十分优秀!