findfirst函数的用法
函数名称: findfirst
函数原型: int findfirst(char *fname,struct ffblk *ptr,int attrib)
函数功能: 寻找与fname相匹配的第一个文件名称
函数返回:
参数说明: ptr-保存查找到的文件信息
所属文件: <dir.h >
#include <stdio.h >
#include <dir.h >
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);
这只限于windows ,而在linux下使用打开文件夹 要用opendir ,头文件是dirent.h
The strncasecmp() function compares two strings.
strncasecmp()函数的作用是:比较字符串的前n个字符(大小写不敏感)。
This function returns:
这个函数将返回下列值:
strncasecmp(string1,string2,length) |
Parameter参数 | Description描述 |
---|---|
string1 | Required. Specifies the first string to compare 必要参数。指定参与比较的第一个字符串对象 |
string2 | Required. Specifies the second string to compare 必要参数。指定参与比较的第二个字符串对象 |
length | Required. Specify the number of characters from each string to be used in the comparison 必要参数。指定每个字符串中参数比较的字符数量 |
Note: The strncasecmp() is binary safe and case-insensitive.
注意:strncasecmp()函数是二进制精确的,并且它不区分字母大小写。
<?php echo strncasecmp("Hello world!","hello earth!",6); ?> |
The output of the code above will be:
上述代码将输出下面的结果:
0 |