LabWindows/CVI

Content Type
Programming Language
Current manual
Table of Contents

strncmp

strncmp

int strncmp (const char string1[], const char string2[], size_t maxChars);

Purpose

Compares a specified number of characters of two NUL-terminated strings. Characters that follow an ASCII NUL byte are not compared. The comparison is based upon the value of the characters in the strings interpreted as unsigned chars. The comparison is case-sensitive.

Parameters

Input
Name Type Description
string1 const char [] Contains a pointer to the string that is compared to string2.
string2 const char [] Contains a pointer to the string that is compared to string1.
maxChars size_t Specifies the maximum number of characters to compare between the two specified strings.
Note Note  Characters that follow an ASCII NUL byte are not compared.

Return Value

Name Type Description
comparisonResult int Contains the result of the comparison between the two specified strings. The comparison is based on the value of the characters, interpreted as unsigned chars. The comparison is case-sensitive. The following explains the possible return values:
Result Description
Positive integer string1 is greater than string2
Zero string1 is equal to string2
Negative integer string1 is less than string2

Additional Information

Library: ANSI C Library

Include file: ansi_c.h

LabWindows/CVI compatibility: LabWindows/CVI 3.0 and later

Examples

Refer to the following examples that use the strncmp function:

  • apps\uirview\uirview.cws

    Open example
  • functionpanels\Customization\SelectColor.cws

    Open example
Was this information helpful?

Previous

strcmp

Previous

strcmp