SW006013 Microchip Technology, SW006013 Datasheet - Page 138

MPLAB C Compiler For DsPIC DSCs

SW006013

Manufacturer Part Number
SW006013
Description
MPLAB C Compiler For DsPIC DSCs
Manufacturer
Microchip Technology
Series
DsPIC30F/33Fr
Type
MPLAB® C Compilerr
Datasheet

Specifications of SW006013

Supported Families
DsPIC30F, DsPIC33F
Core Architecture
DsPIC
Kit Contents
Software And Docs
Mcu Supported Families
DsPIC30F And DsPIC33F
Tool Function
Compiler
Tool Type
Compiler
Processor Series
dsPIC
Lead Free Status / RoHS Status
na
For Use With/related Products
dSPIC DSCs
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
DS51456E-page 134
strspn (Continued)
strstr
Description:
Include:
Prototype:
Arguments:
Return Value:
Remarks:
Example:
Output:
strspn("animal", "aeiounm") = 5
strspn("animal", "aimnl") = 6
strspn("animal", "xyz") = 0
Explanation:
In the first result, l is not in s2.
In the second result, the terminating null is not in s2.
In the third result, a is not in s2 , so the comparison stops.
Search for the first occurrence of a string inside another string.
<string.h>
char *strstr(const char *s1, const char *s2);
s1
s2
Returns the address of the first element that matches the substring if
found; otherwise, returns a null pointer.
This function will find the first occurrence of the string s2 (excluding the
null terminator) within the string s1. If s2 points to a zero length string,
s1 is returned.
#include <string.h> /* for strstr, NULL */
#include <stdio.h>
int main(void)
{
if (ptr != NULL)
char str1[20] = "What time is it?";
char str2[20] = "is";
char str3[20] = "xyz";
char *ptr;
int res;
printf("str1 : %s\n", str1);
printf("str2 : %s\n", str2);
printf("str3 : %s\n\n", str3);
ptr = strstr(str1, str2);
{
}
else
res = ptr - str1 + 1;
printf("\"%s\" found at position %d\n",
printf("\"%s\" not found\n", str2);
str2, res);
pointer to the string to be searched
pointer to substring to be searched for
/* for printf
© 2008 Microchip Technology Inc.
*/

Related parts for SW006013