Skip to main content
Open topic with navigation CAPL Functions » General » Function Overview » strstr, strstr_off

strstr, strstr_off

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

Function Syntax

long strstr(char s1[], char s2[]);
long strstr_off(char s1[], long offset, char s2[]);

Description

Searches in s1 for s2. Note: A character may need several bytes depending on the string encoding, e.g., Japanese characters in Windows ANSI (932) encoding or any special characters in UTF-8 encoding. In that case, you should use mbstrstr/mbstrstr_off instead.

Parameters

  • s1: First string
  • offset: Offset in s1 in bytes at which the search shall be started
  • s2: Second string

Return Values

First position in bytes of s2 in s1, or -1 if s2 is not found in s1.

Example

long pos;
char s1[18] = "Vector Informatik";
char s2[11] = "Informatik";
pos = strstr(s1, s2); // pos = 7
strlenstrncatstrncpyString Literal