SW006014 Microchip Technology, SW006014 Datasheet - Page 116

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
DS51456E-page 112
strtoul
Description:
Include:
Prototype:
Arguments:
Return Value:
Remarks:
Example:
Converts a partial string to an unsigned long integer.
<stdlib.h>
unsigned long strtoul(const char *s, char **endptr,
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 strtoul */
int main(void)
{
}
Output:
String = "12BGET3"
Stopped at: T3
String = "0x1234Number"
Stopped at: Number
String = "-123abc"
Stopped at: abc
int base);
char *end;
char a[] = "12BGET3";
char b[] = "0x1234Number";
char c[] = "-123abc";
unsigned long x;
x = strtoul(a, &end, 25);
printf("String = \"%s\"
printf("Stopped at: %s\n\n", end );
x = strtoul(b, &end, 0);
printf("String = \"%s\"
printf("Stopped at: %s\n\n", end );
x = strtoul(c, &end, 0);
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 = 429164
long = 4294967173
long = 4660
long = %lu\n", a, x );
long = %lu\n", b, x );
long = %lu\n", c, x );
© 2008 Microchip Technology Inc.
*/

Related parts for SW006014