SW006014 Microchip Technology, SW006014 Datasheet - Page 119

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.
memchr (Continued)
memcmp
Description:
Include:
Prototype:
Arguments:
Return Value:
Remarks:
Example:
if (ptr != NULL)
}
Output:
buf1 : What time is it?
i found at position 7
y not found
Compare the contents of two buffers.
<string.h>
int memcmp(const void *s1, const void *s2, size_t n);
s1
s2
n
Returns a positive number if s1 is greater than s2, zero if s1 is equal to
s2, or a negative number if s1 is less than s2.
This function compares the first n characters in s1 to the first n charac-
ters in s2 and returns a value indicating whether the buffers are less
than, equal to or greater than each other.
#include <string.h> /* memcmp
#include <stdio.h>
int main(void)
{
printf("\n");
ptr = memchr(buf1, ch2, 50);
{
}
else
char buf1[50] = "Where is the time?";
char buf2[50] = "Where did they go?";
char buf3[50] = "Why?";
int res;
printf("buf1 : %s\n", buf1);
printf("buf2 : %s\n", buf2);
printf("buf3 : %s\n\n", buf3);
res = memcmp(buf1, buf2, 6);
if (res < 0)
else if (res == 0)
else
res = ptr - buf1 + 1;
printf("%c found at position %d\n", ch2, res);
printf("%c not found\n", ch2);
printf("buf1 comes before buf2\n");
printf("6 characters of buf1 and buf2 "
printf("buf2 comes before buf1\n");
"are equal\n");
first buffer
second buffer
number of characters to compare
/* for printf */
*/
DS51456E-page 115

Related parts for SW006014