Microchip Technology XC8 Standard Compiler (Workstation) SW006021-1 SW006021-1 User Manual

Product codes
SW006021-1
Page of 518
MPLAB
®
 XC8 C Compiler User’s Guide
DS52053B-page 364
 2012 Microchip Technology Inc.
Example
#include <stdio.h>
#include <string.h>
void 
main (void)
{
    static char set[] = "xyz";
    printf("%d\n", strcspn("abcdevwxyz", set));
    printf("%d\n", strcspn("xxxbcadefs", set));
    printf("%d\n", strcspn("1234567890", set));
}
See Also
strspn()
Return Value
Returns the length of the segment.
STRLEN 
Synopsis
#include <string.h>
 
size_t strlen (const char * s)
Description
The 
strlen()
 function returns the number of characters in the string 
s
, not including 
the null terminator.
Example
#include <string.h>
#include <stdio.h>
void 
main (void)
{
    char buffer[256];
    char * s1, * s2;
    strcpy(buffer, "Start of line");
    s1 = buffer;
    s2 = "... end of line";
    strcat(s1, s2);
    printf("Length = %d\n", strlen(buffer));
    printf("string = \"%s\"\n", buffer);
}
Return Value
The number of characters preceding the null terminator.