SW006014 Microchip Technology, SW006014 Datasheet - Page 115

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.
strtol
Description:
Include:
Prototype:
Arguments:
Return Value:
Remarks:
Example:
Converts a partial string to a long integer.
<stdlib.h>
long strtol(const char *s, char **endptr, int base);
s
endptr
base
Returns the converted number if successful; otherwise, returns 0.
If base is zero, strtol attempts to determine the base automatically.
It can be octal, determined by a leading zero, hexadecimal, determined
by a leading 0x or 0X, or decimal in any other case. If base is specified
strtol converts a sequence of digits and letters a-z (case insensi-
tive), where a-z represents the numbers 10-36. Conversion stops when
an out of base number is encountered. endptr will point to the remain-
der of the string starting with the first unconverted character. If a range
error occurs, errno will be set.
#include <stdio.h>
#include <stdlib.h> /* for strtol */
int main(void)
{
}
Output:
String = "-12BGEE"
Stopped at: GEE
String = "1234Number"
Stopped at: 4Number
char *end;
char a[] = "-12BGEE";
char b[] = "1234Number";
long x;
x = strtol(a, &end, 16);
printf("String = \"%s\"
printf("Stopped at: %s\n\n", end );
x = strtol(b, &end, 4);
printf("String = \"%s\"
printf("Stopped at: %s\n\n", end );
string to be converted
pointer to the character at which the conversion stopped
number base to use in conversion
/* for printf */
long = -299
long = 27
long = %ld\n", a, x );
long = %ld\n", b, x );
DS51456E-page 111

Related parts for SW006014