Findfirst, strncasecmp Function

Source: Internet
Author: User

Usage of findfirst Function
Function Name: findfirst
Function prototype: int findfirst (char * fname, struct ffblk * PTR, int attrib)
Function: find the name of the first file that matches the fname.
Function return:
Parameter description: PTR-Save the information of the searched File
File: <dir. h>

# Include <stdio. h>
# Include <dir. h>
Int main ()
{
Struct ffblk;
Int done;
Printf ("Directory Listing *.*");
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) to find the specified file.
Returns 0.
Pathname is the specified directory name and file name, for example, "C: // WPS // TXT"
Ffblk is a specified structure for saving file information. It is defined as follows:
When there are too many threads, there are too many threads, too many threads.
Explain struct ffblk success
Detail {detail
Optional char ff_reserved [21];/* dos reserved words */reserved
Optional char ff_attrib;/* file attributes */optional
Optional int ff_ftime;/* file time */optional
Optional int ff_fdate;/* file date */optional
Optional long ff_fsize;/* file length */optional
Optional char ff_name [13];/* file name */optional
} Else
When there are too many threads, there are too many threads, too many threads.
Attrib is a file attribute, represented by the following characters
When there are too many threads, there are too many threads, too many threads.
┃ Fa_rdonly read-only file named internal fa_label volume number Internal
Invalid fa_hidden: Hide the file named "invalid fa_direc ".
Invalid fa_system System File internal fa_arch file external
When there are too many threads, there are too many threads, too many threads.
Example:
Struct ffblk ff;
Findfirst ("*. wps", & ff, fa_rdonly );
 
This is only for windows, but opendir is used to open a folder in Linux. the header file is dirent. h.

 

 

 

Definition and usage
Definition and usage

The strncasecmp () function compares two strings.
The strncasecmp () function compares the first n characters of a string (Case Insensitive ).

This function returns:
This function returns the following values:

  • 0-if the two strings are equal
    0-if the string is equal
  • <0-If string1 is less than string2
    <0-If string1 is smaller than string2
  • > 0-If string1 is greater than string2
    > 0-If string1 is greater than string2
Syntax
Syntax

strncasecmp(string1,string2,length)

Parameter Parameters Description
String1 Required. specifies the first string to compare
Required parameter. Specifies the first string object involved in the comparison
String2 Required. specifies the second string to compare
Required parameter. Specify the second string object involved in the comparison
Length Required. specify the number of characters from each string to be used in the comparison
Required parameter. Specify the number of characters for Parameter comparison in each string
Tips and notes
Notes

Note:The strncasecmp () is binary safe and case-insensitive.
Note: The strncasecmp () function is binary accurate and case-insensitive.

Example
Case

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

The output of the code above will be:
The above code will output the following results:

0

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.