// app1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "app1.h"
#include <vector>
#include <algorithm>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// The one and only application object
CWinApp theApp;
using namespace std;
int cmp(const char * &a, const char * &b)
{
return strcmp(a, b) < 0;
}
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
// initialize MFC and print and error on failure
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// TODO: change error code to suit your needs
cerr << _T("Fatal Error: MFC initialization failed") << endl;
nRetCode = 1;
}
else
{
// TODO: code your application's behavior here.
//CString strHello;
//strHello.LoadString(IDS_HELLO);
//cout << (LPCTSTR)strHello << endl;
_WIN32_FIND_DATAA fd;
vector<char *> list;
char * filename;
HANDLE h = FindFirstFile("c:\\*.*", &fd);
int r = 1;
while (h != INVALID_HANDLE_VALUE && r != 0)
{
if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
if (strcmp(fd.cFileName, ".") && strcmp(fd.cFileName, ".."))
{
filename = new char[_MAX_PATH + 1];
strcpy(filename, fd.cFileName);
list.push_back(filename);
}
}
r = FindNextFile(h, &fd);
}
sort(list.begin(), list.end(), cmp);
for (vector<char *>::iterator it = list.begin(); it != list.end(); it++)
{
cout<< *it << endl;
}
}
return nRetCode;
}
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。