麻烦修改程序

jennyfy 2009-03-04 08:08:30

#include<iostream>
#include<string>
#include<afx.h>
using namespace std;
void find(char *IpPath)
{
char szFind[100];
char szFile[100];
WIN32_FIND_DATA FindFileData;
strcpy(szFind,IpPath);
strcat(szFind,"*.*");
HANDLE hFind=::FindFirstFile(szFind,&FindFileData);
if(INUALID_HANDLE_VALUE==hFind)
return;
while(true)
{
if(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
if(FindFileData.cFileName[0]!='.')
{
strcpy(szFile,IpPath);
strcat(szFile."");
strcat(szFile,FindFileData.cFileName);
find(szFile);
}
}
else
{
cout<<eData.cFileName;
}
if(!FindNextFile(hFind,&FindFileData))
break;
}
FindClose(hFind);
}
void main()
{
char *p="F:\text";
find(p);
}

以上是遍历文件夹的程序,出现了下流错误,麻烦帮忙修改,谢谢
c:\documents and settings\administrator\11.cpp(13) : error C2065: 'INUALID_HANDLE_VALUE' : undeclared identifier
c:\documents and settings\administrator\11.cpp(13) : error C2446: '==' : no conversion from 'void *' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
c:\documents and settings\administrator\11.cpp(13) : error C2040: '==' : 'int' differs in levels of indirection from 'void *'
c:\documents and settings\administrator\11.cpp(22) : error C2059: syntax error : 'string'
c:\documents and settings\administrator\11.cpp(23) : error C2228: left of '.strcat' must have class/struct/union type
c:\documents and settings\administrator\11.cpp(23) : error C2228: left of '.cFileName' must have class/struct/union type
c:\documents and settings\administrator\11.cpp(29) : error C2065: 'eData' : undeclared identifier
c:\documents and settings\administrator\11.cpp(29) : error C2228: left of '.cFileName' must have class/struct/union type
c:\documents and settings\administrator\11.cpp(48) : error C2018: unknown character '0xa1'
c:\documents and settings\administrator\11.cpp(48) : error C2018: unknown character '0xa1'
c:\documents and settings\administrator\11.cpp(48) : error C2018: unknown character '0xa1'
c:\documents and settings\administrator\11.cpp(48) : error C2018: unknown character '0xa1'
c:\documents and settings\administrator\11.cpp(48) : error C2018: unknown character '0xa1'
c:\documents and settings\administrator\11.cpp(48) : error C2018: unknown character '0xa1'
c:\documents and settings\administrator\11.cpp(48) : error C2018: unknown character '0xa1'
c:\documents and settings\administrator\11.cpp(48) : error C2018: unknown character '0xa1'
执行 cl.exe 时出错.
...全文
132 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
jennyfy 2009-03-06
  • 打赏
  • 举报
回复
谢谢你,我会按照您提供的方法学习的
zhkefa 2009-03-05
  • 打赏
  • 举报
回复
2楼的广告是手动加上去的,还是有什么工具的,挺有意思的。
sanguomi 2009-03-04
  • 打赏
  • 举报
回复
2楼很有意思
creep123 2009-03-04
  • 打赏
  • 举报
回复
汗,,我也顶一下2楼
malpin 2009-03-04
  • 打赏
  • 举报
回复
2楼在做广告
哈哈
  • 打赏
  • 举报
回复
2楼真细心,顶一个
fairchild811 2009-03-04
  • 打赏
  • 举报
回复
支持一下,2楼的在做广告
wxgiter 2009-03-04
  • 打赏
  • 举报
回复
2楼是正解,写程序注意拼写错误,呵呵
zclever 2009-03-04
  • 打赏
  • 举报
回复
2楼够详细啊
乔乔公爵 2009-03-04
  • 打赏
  • 举报
回复
/******************************************************************************
*
* 演示查找文件功能
*
* 操作系统: Windows XP Home Edition Service Pack 3
* 开发环境: Visual Studio . NET 2008 Service Pack 1
* 作者: 高宏伟
* 时间: 2009-03-04 22:04:02
* QQ: 21807822
* Blog: http://blog.donews.com/dukejoe/
* 地点: 黑龙江省哈尔滨市道里区通达街
* 注释: 新建一个Console工程,默认即可,不需要新文件
*****************************************************************************/
#include <iostream>
#include <string>
// 高宏伟 加入windows.h
#include <windows.h>

using namespace std;

void find(char *IpPath)
{
char szFind[100];
char szFile[100];
WIN32_FIND_DATA FindFileData;
strcpy(szFind,IpPath);
strcat(szFind,"*.*");
HANDLE hFind=::FindFirstFile(szFind,&FindFileData);
// 高宏伟 你的单词写错了
//if(INUALID_HANDLE_VALUE==hFind)
if (INVALID_HANDLE_VALUE == hFind)
return;
while(true)
{
if(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
if(FindFileData.cFileName[0]!='.')
{
strcpy(szFile,IpPath);
// 高宏伟 你用的是. 这里是函数,参数之间要用逗号
//strcat(szFile."");
strcat(szFile,"");
strcat(szFile,FindFileData.cFileName);
// 高宏伟 如果要遍历子目录,这里要加上 *.*
strcat(szFile,"\\*.*");
find(szFile);
}
}
else
{
cout <<FindFileData.cFileName << endl ;
}
if(!FindNextFile(hFind,&FindFileData))
break;
}
FindClose(hFind);
}
void main()
{
// 高宏伟 我随便改了一个文件比较多的目录做测试。
// 字符串的最后要加上 \\
// 在C语言里\\ 才代表\ 这里我改动了一下。
char *p="D:\\TDDOWNLOAD\\";
find(p);
}


在学好VC之前,一定要先学C,再学C++,再学数据结构,然后再学VC,你会减少很多的麻烦
bfhtian 2009-03-04
  • 打赏
  • 举报
回复
不是有错误提示吗'INUALID_HANDLE_VALUE' : undeclared identifier ,有定义这个变量吗

65,211

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧