c - 为什么 fopen 文件夹失败?

标签 c windows visual-studio file

此代码有效。

pFile = fopen("d:\myfile.txt", "w");

此代码不起作用。

pFile = fopen("d:\ABC\myfile.txt", "w");

我确实有这个文件夹 d:\ABC

操作系统是 Windows 10,使用 Visual Studio 2019。

错误号是22。

最佳答案

//these are all the same
char test1[]={'\n', '\a','\t','\\','\'','\"','\0'};
char test2[]={'\N', '\A','\T','\\','\'','\"','\0'};
char test3[]={10,7,9,92,39,34,0};
char test4[]={0x0a,0x07,0x09,0x5c,0x27,0x22,0x00};
char test5[]="\n\a\t\\\'\"";
char test6[]="\N\A\T\\\'\"";

使用 Microsoft 文件

“d:\\ABC\\myfile.txt”;

“d:/ABC/myfile.txt”;

关于c - 为什么 fopen 文件夹失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56439011/

相关文章:

c++ - MSVC 2017 中 STL 容器的移动构造函数未标记为 noexcept

c++ - 如何在裸机上运行 gcov(没有文件系统)

c# - 自定义控件退出时光标未更改

c - 如何在 Linux 中用 C 写文件?

windows - 无法找到用于在 VS 2015 中创建 Visual C++ Windows 服务的模板

c++ - 我可以使用 FindFirstChangeNotification 和 FindNextChangeNofication 而不是 ReadDirectoryChangesW 获取指定目录中的文件信息更改吗?

.net - 系统.Data.SQLite.SQLiteException : Database is locked?

c++ - Visual Studio 中的安全开发生命周期检查选项是什么?

c - 将 sprintf 与 unicode 字符一起使用

java - 为什么树遍历的PreOrder、InOrder、PostOrder中总是LEFT先于RIGHT遍历