当前位置:网站首页>_findnext 报错
_findnext 报错
2022-04-23 05:50:00 【ppipp1109】
ps:编译环境 qt + mingw32 编译没问题;
换到qt + msvc 2017_64 就出现问题;
报错信息:
Stopped in thread 0 by: Exception at 0x7ffbcfe713ad, code: 0xc0000005: write access violation at: 0xffffffffd587d380, flags=0x0 (first chance).
//获取目录下的所有文件名
void getFiles(string path, vector<string>& files)
{
//文件句柄
long hFile = 0;
//文件信息
struct _finddata_t fileinfo;
string p;
if ((hFile = _findfirst(p.assign(path).append("\\*").c_str(), &fileinfo)) != -1)
{
do
{
//如果是目录,迭代之
//如果不是,加入列表
if ((fileinfo.attrib & _A_SUBDIR))
{
if (strcmp(fileinfo.name, ".") != 0 && strcmp(fileinfo.name, "..") != 0)
getFiles(p.assign(path).append("\\").append(fileinfo.name), files);
}
else
{
files.push_back(p.assign(path).append("\\").append(fileinfo.name));
}
} while (_findnext(hFile, &fileinfo) == 0);
_findclose(hFile);
}
}
应用下面这个函数的时候, 报错上面的错误。折腾了一下午,起初以为是编码格式问题,最后发现是64位编译器,反馈的结构体的值保存的是64位,定义的 long 型hFile 会被截断,对不上了。
所以将long hfile 改为
intptr_t hFile
或者
long long hFIle
版权声明
本文为[ppipp1109]所创,转载请带上原文链接,感谢
https://ppipp.blog.csdn.net/article/details/124328853
边栏推荐
- Initialization of classes and objects (constructors and destructors)
- Easy to use data set and open source network comparison website
- C语言的运算符
- Matlab calibration board corner detection principle
- C语言输入和输出(printf和scanf函数、putchar和getchar函数)
- Programmers can also write novels
- Uniapp encapsulates request
- sqlite3加密版
- 【UDS统一诊断服务】三、应用层协议(2)
- 在visual stdio中运行qt程序
猜你喜欢
随机推荐
P1018 maximum product solution
Robocode教程5——Enemy类
File viewing commands and user management commands
[UDS unified diagnostic service] IV. typical diagnostic service (2) - data transmission function unit
[UDS unified diagnosis service] IV. typical diagnosis service (3) - read fault information function unit (storage data transmission function unit)
The most practical chrome plug-in
Object转Json差异之Gson fastJson jackson 修改字段名
[ThreadX] h743zi + lan8720 + ThreadX + netx duo transplantation
Rust:在线程池中共享变量
C语言进阶要点笔记2
Generate random number
gcc ,g++,gdb的安装
Latex configuration and use
[UDS unified diagnostic service] II. Network layer protocol (2) - data transmission rules (single frame and multi frame)
[UDS] unified diagnostic service (UDS)
【UDS统一诊断服务】三、应用层协议(2)
Make your own small program
C#【文件操作篇】按行读取txt文本
猜數字遊戲
Basemap库绘制地图