Skip to main content
Open topic with navigation CAPL Functions » General » Function Overview » mbstrncmp, mbstrncmp_off

mbstrncmp, mbstrncmp_off

Valid for: CANoe DE • CANoe:lite DE • CANoe4SW DE • CANoe4SW:lite DE

Function Syntax

  • long mbstrncmp(char s1[], char s2[], long len); // form 1
  • long mbstrncmp(char s1[], char s2[], long s2offset, long len); // form 2
  • long mbstrncmp_off(char s1[], long s1offset, char s2[], long s2offset, long len); // form 3

Description

This function compares s1 with s2 for a maximum of len characters. If they are identical the functional result is 0.
If s1 is less than s2 the result is -1, else +1.
Comparison starts in s1 at s1offset (form 3) and in s2 at s2offset (form 2 and form 3).

Parameters

  • s1: First string
  • s2: Second string
  • len: Maximum number of characters to compare
  • s1offset: Offset in s1 in characters
  • s2offset: Offset in s2 in characters

Return Values

  • -1: if s1 is less than s2.
  • 1: if s2 is less than s1.
  • 0: if the strings are equal.

Example

char s[50] = "'Tür' is the german word for 'door'.";
write("%d", mbstrncmp_off(s, 13, "german", 0, 6)); // 0
strncmpmbstrlenmbstrncpymbstrstr