Strncmp () function

Source: Internet
Author: User

I met the strncmp function in my work. When I switched from C to Java, I did not know its return value range. As a result, an error occurs, and the outsourcer cannot record the order, the problem is serious. Below is a pieceCode:
If (strcmp (sctctcde, "014012") = 0 ){
If (strcmp (sbsnstyp, "19001") = 0) | (strcmp (sbsnstyp, "19007") = 0 )){
Sprintf (stmp, "This Department attribute is exclusive4s storesThe business source can only be an agency proxy! ");
Return (setusererror (lpinbuffer, 2, stmp ));
}Else if (strncmp (sprodno, "03", 2) {// if equal, return 0 instead of true.
Sprintf (stmp, "this department is an exclusive 4s store and can only provide auto insurance services! ");
Return (setusererror (lpinbuffer, 2, stmp ));
}
}

 
Strncmp () function usage

The function is used to compare the first n characters (case sensitive) of a string ).

This function returns the following values:
0-if the string is equal
<0-If string1 is smaller than string2
> 0-If string1 is greater than string2

Syntax: strncmp (string1, string2, length)

 

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.