findfirst用法

作者&投稿:栋兔 (若有异议请与网页底部的电邮联系)
C语言中的findfirst()参数是什么?如何使用?~

函数名称: findfirst
函数原型: int findfirst(char *fname,struct ffblk *ptr,int attrib)
函数功能: 寻找与fname相匹配的第一个文件名称
函数返回:
参数说明: ptr-保存查找到的文件信息
所属文件:

#include
#include
int main()
{
struct ffblk ffblk;
int done;
printf("Directory listing of *.*");
done=findfirst("*.*",&ffblk,0);
while (!done)
{
printf("%s", ffblk.ff_name);
done=findnext(&ffblk);
}
return 0;
}

int findfirst(char *pathname,struct ffblk *ffblk,int attrib)查找指定的文件,成功
返回0
pathname为指定的目录名和文件名,如"C:\\WPS\\TXT"
ffblk为指定的保存文件信息的一个结构,定义如下:
┏━━━━━━━━━━━━━━━━━━┓
┃struct ffblk ┃
┃{ ┃
┃ char ff_reserved[21]; /*DOS保留字*/┃
┃ char ff_attrib; /*文件属性*/ ┃
┃ int ff_ftime; /*文件时间*/ ┃
┃ int ff_fdate; /*文件日期*/ ┃
┃ long ff_fsize; /*文件长度*/ ┃
┃ char ff_name[13]; /*文件名*/ ┃
┃} ┃
┗━━━━━━━━━━━━━━━━━━┛
attrib为文件属性,由以下字符代表
┏━━━━━━━━━┳━━━━━━━━┓
┃FA_RDONLY 只读文件┃FA_LABEL 卷标号┃
┃FA_HIDDEN 隐藏文件┃FA_DIREC 目录 ┃
┃FA_SYSTEM 系统文件┃FA_ARCH 档案 ┃
┗━━━━━━━━━┻━━━━━━━━┛
例:
struct ffblk ff;
findfirst("*.wps",&ff,FA_RDONLY);

string::size_type 是表示数据结构大小的类型,通常是unsigned long。
s.find_first_of(letter, pos)),意思是在s中寻找首个letter中有的字符,从pos开始搜索。
例如string s = "1a2b3c", letter = "abc"; s.find(letter)就是1,即'a'出现的位置
s.find(letter, 2)就是3,是从第二个字符后面"2b3c"开始搜第一个在"abd"中出现的字符。所以是'b'。因此是3

int findfirst(char *pathname, struct ffblk *ffblk, int attrib);
attrib是标志位,用于
FA_RDONLY 只读文件┃FA_LABEL 卷标号┃
FA_HIDDEN 隐藏文件┃FA_DIREC 目录 ┃
FA_SYSTEM 系统文件┃FA_ARCH 档案 ┃

1.p=findfirst ("*.*",&dirment,0x3f);
用于查找当前文件夹下所有文件,direment存放查找结果,0x3f就是2进制的00111111,表示六个标志位全满,FA_RDONLY|FA_LABEL|FA_HIDDEN|FA_DIREC|FA_SYSTEM|FA_ARCH = 1|10|100|1000|10000|100000 = 0x3f.

2.if (!p&&dirment.ff_name[0]=='.'))
'.’表示当前目录,组合起来如果查找结果有当前目录,那继续在当前目录查找。

3.if ((dirment.ff_attrib&0x10)==FA_DIREC) );
表示如果查找结果位目录的话,就继续递归查找目录下面的文件。

函数名: findfirst, findnext
功 能: 搜索磁盘目录; 取得下一个匹配的findfirst模式的文件
用 法: int findfirst(char *pathname, struct ffblk *ffblk, int attrib);
int findnext(struct ffblk *ffblk);
程序例:

/* findnext example */

#include <stdio.h>
#include <dir.h>

int main(void)
{
struct ffblk ffblk;
int done;
printf("Directory listing of *.*\n");
done = findfirst("*.*",&ffblk,0);
while (!done)
{
printf(" %s\n", ffblk.ff_name);
done = findnext(&ffblk);
}

return 0;
//---
不想说你什么了,自己看不明白,还JJYY,F了U


.net 取指定范围内的字符串
int j = s.IndexOf("<*>", i + 2);\/\/获得第二个<*>位置 string sss = s.Substring(i + 3, j - i-3);\/\/去子字符串 sss就是你要的结果

JAVASCRIPT脚本有点不懂哦,大家帮我看看啊
{ ind = i; break; } } return ind; } 定义一个函数getIndex,功能是获得变量ind的值。function arrange(){ nextY = document.layers[firstInd].pageY +document.layers[firstInd].document.height;for (i=firstInd+1; i<document.layers.length; i++){ whichEl = document.layers[i];if ...

双城市13686824312: findfirst用法 -
止治凯福: int findfirst(char *pathname, struct ffblk *ffblk, int attrib); attrib是标志位,用于 FA_RDONLY 只读文件┃FA_LABEL 卷标号┃ FA_HIDDEN 隐藏文件┃FA_DIREC 目录 ┃ FA_SYSTEM 系统文件┃FA_ARCH 档案 ┃ 1.p=findfirst ("*.*",&dirment,0x3...

双城市13686824312: c语言的findfirst()怎么用? -
止治凯福: 你好,system("dir");不知道是不是你要的 但是C语言下一样有象windows下的FindFirstFile和FindNextFile一样功能的函数:_findfirst和_findnext,使用方法和windows下的一样,你可以查查帮助,不过需要包含io.h 23034希望对你有帮助!

双城市13686824312: C语言里面findfirst和findfirstfile的区别是什么? -
止治凯福: findfirst函数原型是int findfirst(char *pathname,struct ffblk *ffblk,int attrib);是查找指定的文件(查找pathname)如果查找成功返回0 ,它一般与findnext一起用,用于对某个目录进行全部文件扫描. findfirstfile我不是特别清楚,我认为在C中,返...

双城市13686824312: vb 使用findfirst查找数据 -
止治凯福: movenext 可以配合循环一条一条查,也可以用条件where,sql语句来查9月

双城市13686824312: 关于c语言中文件搜索函数. -
止治凯福: 函数名: findfirst, findnext 功能: 搜索磁盘目录; 取得下一个匹配的findfirst模式的文件 用法: int findfirst(char *pathname, struct ffblk *ffblk, int attrib); int findnext(str...

双城市13686824312: vb中find first 的用法 -
止治凯福: data1.recordset.findfirst“姓名='"&text2.ext & "'" 太急了,对不起,既然这样再补充一下吧,这个findfirst 是与nomatch 配合使用的 nomatch的意思是没有找到,所以当它的值为TRUE时是说明没有找到您要找的项目,而如果是FALSE的话就是指找到了.if data1.recordset.nomatch=ture then msgbox "没有找到记录" end if

双城市13686824312: findfirst, findnext的用 法 -
止治凯福: int findfirst(char *pathname, struct ffblk *ffblk, int attrib); int findnext(struct ffblk *ffblk);

双城市13686824312: C语言,求大神(简单地)介绍下FindFirstFile和FindNextFile的用法 ,最好带上简单易理解的例子```
止治凯福://遍历文件夹函数void TraverseFolder(LPCTSTR lpPath){ TCHAR szFind[MAX_PATH] = {_T("\0")}; WIN32_FIND_DATA findFileData; BOOL bRet; _tcscpy_s(szFind, MAX_PATH, lpPath); _tcscat_s(szFind, _T("\\*.*")); //这里一定要指明通配...

双城市13686824312: C语言如何遍历目录 (C++也可以) findfirst findnext怎么用? -
止治凯福: #include FILE *fp;void findFile(char filePath[])//这个是你要的函数{ char szFind[MAX_PATH];//这是要找的 WIN32_FIND_DATA FindFileData; HANDLE hFind; char szFile[MAX_PATH]; strcpy(szFind,filePath); strcat(szFind,"\\*.*");//利用通配...

双城市13686824312: 谁能告诉我,查找进程的内存的程序中的两函数FindFirst()和FindNext()分别指什么?
止治凯福: FindFirst找到的值,不一定就是你要的那个变量. 比如x=123,y=123 在内存中你找不到x的位置的,你只能找出所有123的位置,然后另行判断哪一个123是x.

你可能想看的相关专题

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 星空见康网