SW006014 Microchip Technology, SW006014 Datasheet - Page 100

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 96
atol (Continued)
Example:
bsearch
Description:
Include:
Prototype:
Arguments:
Return Value:
Remarks:
#include <stdio.h>
#include <stdlib.h> /* for atol
int main(void)
{
}
Output:
String = " -123456"
String = "2Number"
Performs a binary search
<stdlib.h>
void *bsearch(const void *key, const void *base,
key
base
nelem
size
cmp
ck
ce
Returns a pointer to the object being searched for if found; otherwise,
returns NULL.
The value returned by the compare function is <0 if ck is less than ce,
0 if ck is equal to ce, or >0 if ck is greater than ce.
In the following example, qsort is used to sort the list before bsearch
is called. bsearch requires the list to be sorted according to the com-
parison function. This comp uses ascending order.
size_t nelem, size_t size,
int (*cmp)(const void *ck, const void *ce));
char a[] = " -123456";
char b[] = "2Number";
long x;
x = atol(a);
printf("String = \"%s\"
x = atol(b);
printf("String = \"%s\"
object to search for
pointer to the start of the search data
number of elements
size of elements
pointer to the comparison function
pointer to the key for the search
pointer to the element being compared with the key.
/* for printf */
int = -123456
int = 2
int = %ld\n", a, x);
int = %ld\n", b, x);
© 2008 Microchip Technology Inc.
*/

Related parts for SW006014