findfirst,strncasecmp函数

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

 

 

 

Definition and Usage
定义和用法

The strncasecmp() function compares two strings.
strncasecmp()函数的作用是:比较字符串的前n个字符(大小写不敏感)。

This function returns:
这个函数将返回下列值:

  • 0 - if the two strings are equal
    0 – 如果字符串相等
  • <0 - if string1 is less than string2
    <0 – 如果string1小于string2
  • >0 - if string1 is greater than string2
    >0 – 如果string1大于string2

Syntax
语法

strncasecmp(string1,string2,length)

Parameter参数Description描述
string1Required. Specifies the first string to compare
必要参数。指定参与比较的第一个字符串对象
string2Required. Specifies the second string to compare
必要参数。指定参与比较的第二个字符串对象
lengthRequired. Specify the number of characters from each string to be used in the comparison
必要参数。指定每个字符串中参数比较的字符数量


Tips and Notes
注意点

Note: The strncasecmp() is binary safe and case-insensitive.
注意:strncasecmp()函数是二进制精确的,并且它不区分字母大小写。


Example
案例

<?php
echo strncasecmp("Hello world!","hello earth!",6);
?>

The output of the code above will be:
上述代码将输出下面的结果:

0

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值