User manual

Table Of Contents
mikroC PRO for PIC32
MikroElektronika
625
strncmp
Prototype
int strncmp(char *s1, char *s2, char len);
Description Function lexicographically compares not more than len characters (characters that follow the null
character are not compared) from the string pointed by s1 to the string pointed by s2. The function
returns a value indicating the s1 and s2 relationship:
Value Meaning
< 0 s1 “less than” s2
= 0 s1 “equal to” s2
> 0 s1 “greater than” s2
Example
char txt = “mikroElektronika”;
char txt_sub = “mikro”;
int res;
res = strncmp(txt_sub,txt,3); // compares the rst 3 characters from the
string ‘txt’ with the sting ‘txt_sub’ and returns a difference
strstr
Prototype
char *strstr(char *s1, char *s2);
Description Function locates the rst occurrence of the string s2 in the string s1 (excluding the terminating null
character).
The function returns pointer to rst occurrence of s2 in s1; if no string was found, function returns 0.
If s2 is a null string, the function returns 0.
Example
char txt = “mikroElektronika”;
char txt_sub = “mikro”;
char *res;
res = strstr(txt_sub,txt);
strcspn
Prototype
char *strcspn(char * s1, char *s2);
Description Function computes the length of the maximum initial segment of the string pointed to by s1 that
consists entirely of characters that are not in the string pointed to by s2.
The function returns the length of the initial segment.
Example
char txt = “mikroElektronika”;
char txt_sub = “mikro”;
char *res;
res = strcspn(txt_sub,txt);