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

製品コード
SW006021-1
ページ / 518
Library Functions
 2012 Microchip Technology Inc.
DS52053B-page 323
Example
#include <stdlib.h>
#include <stdio.h>
void 
main (void)
{
    char buf[80];
    int i;
    gets(buf);
    i = atoi(buf);
    printf(“Read %s: converted to %d\n”, buf, i);
}
See Also
xtoi()
, atof(), atol()
Return Value
A signed integer. If no number is found in the string, 0 will be returned.
ATOL 
Synopsis
#include <stdlib.h>
 
long atol (const char * s)
Description
The 
atol()
 function scans the character string passed to it, skipping leading blanks. It 
then converts an ASCII representation of a decimal number to a long integer.
Example
#include <stdlib.h>
#include <stdio.h>
void 
main (void)
{
    char buf[80];
    long i;
    gets(buf);
    i = atol(buf);
    printf(“Read %s: converted to %ld\n”, buf, i);
}
See Also
atoi()
, atof()
Return Value
A long integer. If no number is found in the string, 0 will be returned.