SW006014 Microchip Technology, SW006014 Datasheet - Page 133

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.
strncmp (Continued)
strncpy
Description:
Include:
Prototype:
Arguments:
Return Value:
Remarks:
Example:
else
}
Output:
buf1 : Where is the time?
buf2 : Where did they go?
buf3 : Why?
6 characters of buf1 and buf2 are equal
buf2 comes before buf1
buf1 comes before buf3
Copy characters from the source string into the destination string, up to
the specified number of characters.
<string.h>
char *strncpy(char *s1, const char *s2, size_t n);
s1
s2
n
Returns a pointer to the destination string.
Copies n characters from the source string to the destination string. If
the source string is less than n characters, the destination is filled with
null characters to total n characters. If n characters were copied and no
null character was found then the destination string will not be null-ter-
minated. If the strings overlap, the behavior is undefined.
#include <string.h> /* for strncpy, strlen */
#include <stdio.h>
int main(void)
{
printf("\n");
res = strncmp(buf1, buf3, 20);
if (res < 0)
else if (res == 0)
char buf1[50] = "We're here";
char buf2[50] = "Where is the time?";
char buf3[50] = "Why?";
char buf4[7]
printf("buf1 : %s\n", buf1);
printf("buf2 : %s\n", buf2);
printf("buf3 : %s\n", buf3);
printf("buf4 : %s\n", buf4);
printf("buf1 comes before buf3\n");
printf("20 characters of buf1 and buf3 "
printf("buf3 comes before buf1\n");
"are equal\n");
destination string to copy to
source string to copy from
number of characters to copy
= "Where?";
/* for printf
DS51456E-page 129
*/

Related parts for SW006014