Product Documentation
Cadence SKILL Language Reference
Product Version IC23.1, November 2023

strncmp

strncmp( 
t_string1 
t_string2 
x_max 
) 
=> 1 / 0 / -1

Description

Compares two argument strings alphabetically only up to a maximum number of characters.

Similar to strcmp except that only up to x_max characters are compared. To test if the contents of two strings are the same, use the equal function.

Arguments

t_string1

First string to be compared.

t_string2

Second string to be compared.

x_max

Maximum number of characters in both strings to be compared.

Value Returned

For the first specified number of characters:

1

t_string1 is alphabetically greater than t_string2

0

t_string1 is alphabetically equal to t_string2.

-1

t_string1 is alphabetically less than t_string2.

Examples

strncmp( "abc" "ab" 3)  
=> 1
strncmp( "abc" "de" 4)  
=> -1
strncmp( "abc" "ab" 2)  
=> 0

Related Topics

String Functions

strcmp


Return to top
 ⠀
X