大家好!请问下这个_findfirst函数
#include<io.h>#include<stdio.h>
#include<stdlib.h>
int main()
{
struct _finddata_t_ file;
long handle;
char *path;
char *format;
path=(char *)malloc(10);
format=(char *)malloc(20);
gets(path);
gets(format);
if((handle=_findfirst(strcat(path,format),&file))==-1L);
{
printf("can not find this format files");
return 1;
}
else
{
printf("%s\n",file.name);
while(_findnext(handle,&file)==0)
{
printf("%s\n",file.name);
}
_findclose(handle);
}
return 0;
}
在VC++6.0和wintc都编译通不过 希望大家指点下 这个究竟怎么用
#include <io.h>
#include <iostream>
using namespace std;
int main()
{
_finddata_t file;
int k;
long HANDLE;
k = HANDLE = _findfirst( "*.*", &file );
while( k != -1 )
{
cout << file.name << endl;
k = _findnext( HANDLE, &file );
}
_findclose( HANDLE );
return 0;
}
c++的写法就可以额!