SW006014 Microchip Technology, SW006014 Datasheet - Page 135

C COMPILER MPLAB FOR PIC24 MCU

SW006014

Manufacturer Part Number
SW006014
Description
C COMPILER MPLAB FOR PIC24 MCU
Manufacturer
Microchip Technology
Type
MPLAB® C Compilerr
Series
PIC24r
Datasheet

Specifications of SW006014

Supported Families
PIC24
Core Architecture
PIC
Kit Contents
Software And Docs
Mcu Supported Families
PIC24
Tool Function
Compiler
Tool Type
Compiler
Processor Series
PIC24
Lead Free Status / RoHS Status
Not applicable / Not applicable
For Use With/related Products
PIC24
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
© 2008 Microchip Technology Inc.
strncpy (Continued)
strpbrk
Description:
Include:
Prototype:
Arguments:
Return Value:
Remarks:
Example:
Explanation:
Each buffer contains the string shown, followed by null characters for a
length of 50. Using strlen will find the length of the string up to but not
including the first null character.
In the first example, 6 characters of buf2 (“Where “) replace the first 6
characters of buf1 ("We're ") and the rest of buf1 remains the same
("here" plus null characters).
In the second example, 18 characters replace the first 18 characters of
buf1 and the rest remain null characters.
In the third example, 5 characters of buf3 ("Why?" plus a null terminat-
ing character) replace the first 5 characters of buf1. buf1 now actually
contains ("Why?", 1 null character, " is the time?", 32 null characters).
strlen shows 4 characters because it stops when it reaches the first
null character.
In the fourth example, since buf4 is only 7 characters strncpy uses 2
additional null characters to replace the first 9 characters of buf1. The
result of buf1 is 6 characters ("Where?") followed by 3 null characters,
followed by 9 characters ("the time?"), followed by 32 null characters.
Search a string for the first occurrence of a character from a specified
set of characters.
<string.h>
char *strpbrk(const char *s1, const char *s2);
s1
s2
Returns a pointer to the matched character in s1 if found; otherwise,
returns a null pointer.
This function will search s1 for the first occurrence of a character
contained in s2.
#include <string.h> /* for strpbrk, NULL */
#include <stdio.h>
int main(void)
{
if (ptr != NULL)
char str1[20] = "What time is it?";
char str2[20] = "xyz";
char str3[20] = "eou?";
char *ptr;
int res;
printf("strpbrk(\"%s\", \"%s\")\n", str1, str2);
ptr = strpbrk(str1, str2);
{
}
else
res = ptr - str1 + 1;
printf("match found at position %d\n", res);
printf("match not found\n");
pointer to the string to be searched
pointer to characters to search for
/* for printf
DS51456E-page 131
*/

Related parts for SW006014