SW006014 Microchip Technology, SW006014 Datasheet - Page 125

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.
strchr
Description:
Include:
Prototype:
Arguments:
Return Value:
Remarks:
Example:
Locates the first occurrence of a specified character in a string.
<string.h>
char *strchr(const char *s, int c);
s
c
Returns a pointer to the location of the match if successful; otherwise,
returns a null pointer.
This function searches the string s to find the first occurrence of the
character c.
#include <string.h> /* for strchr, NULL */
#include <stdio.h>
int main(void)
{
if (ptr != NULL)
if (ptr != NULL)
}
Output:
buf1 : What time is it?
m found at position 8
y not found
char buf1[50] = "What time is it?";
char ch1 = 'm', ch2 = 'y';
char *ptr;
int res;
printf("buf1 : %s\n\n", buf1);
ptr = strchr(buf1, ch1);
{
}
else
printf("\n");
ptr = strchr(buf1, ch2);
{
}
else
res = ptr - buf1 + 1;
printf("%c found at position %d\n", ch1, res);
printf("%c not found\n", ch1);
res = ptr - buf1 + 1;
printf("%c found at position %d\n", ch2, res);
printf("%c not found\n", ch2);
pointer to the string
character to search for
/* for printf
DS51456E-page 121
*/

Related parts for SW006014