Microchip Technology XC8 Standard Compiler (Workstation) SW006021-1 SW006021-1 ユーザーズマニュアル

製品コード
SW006021-1
ページ / 518
MPLAB
®
 XC8 C Compiler User’s Guide
DS52053B-page 370
 2012 Microchip Technology Inc.
STRTOL 
Synopsis
#include <stdlib.h>
 
double strtol (const char * s, const char ** res, int base)
Description
Parse the string s converting it to a long integer type. This function converts the first 
occurrence of a substring of the input that is made up of characters of the expected 
form after skipping leading white-space characters. The radix of the input is determined 
from 
base
. If this is zero, then the radix defaults to base 10. If 
res
 is not NULL, it will be 
made to point to the first character after the converted sub-string.
Example
#include <stdio.h>
#include <strlib.h>
void 
main (void)
{
    char buf[] = "0X299 0x792";
    char * end;
    long in1, in2;
    in1 = strtol(buf, &end, 16);
    in2 = strtol(end, NULL, 16);
    printf("in (decimal): %ld, %ld\n", in1, in2);
}
See Also
strtod()
Return Value
Returns a long int representing the value of the converted input string using the 
specified base.
STRTOK 
Synopsis
#include <string.h>
 
char * strtok (char * s1, const char * s2)
Description
A number of calls to 
strtok()
 breaks the string 
s1
 (which consists of a sequence of 
zero or more text tokens separated by one or more characters from the separator string 
s2
) into its separate tokens.
The first call must have the string 
s1
. This call returns a pointer to the first character of 
the first token, or NULL if no tokens were found. The inter-token separator character is 
overwritten by a null character, which terminates the current token.
For subsequent calls to 
strtok()
s1
 should be set to a NULL. These calls start search-
ing from the end of the last token found, and again return a pointer to the first character 
of the next token, or NULL if no further tokens were found.