SW006013 Microchip Technology, SW006013 Datasheet - Page 132

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 128
strncmp
Description:
Include:
Prototype:
Arguments:
Return Value:
Remarks:
Example:
Compare two strings, up to a specified number of characters.
<string.h>
int strncmp(const char *s1, const char *s2,
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.
strncmp returns a value based on the first character that differs
between s1 and s2. Characters that follow a null character are not
compared.
#include <string.h> /* for strncmp */
#include <stdio.h>
int main(void)
{
size_t n);
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 = strncmp(buf1, buf2, 6);
if (res < 0)
else if (res == 0)
else
printf("\n");
res = strncmp(buf1, buf2, 20);
if (res < 0)
else if (res == 0)
else
printf("buf2 comes before buf1\n");
printf("buf1 comes before buf2\n");
printf("6 characters of buf1 and buf2 "
printf("buf1 comes before buf2\n");
printf("20 characters of buf1 and buf2 "
printf("buf2 comes before buf1\n");
"are equal\n");
"are equal\n");
first string
second string
number of characters to compare
/* for printf
© 2008 Microchip Technology Inc.
*/

Related parts for SW006013