SW006014 Microchip Technology, SW006014 Datasheet - Page 108

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 104
ldiv (Continued)
malloc
Description:
Include:
Prototype:
Argument:
Return Value:
Remarks:
Example:
Output:
For ldiv(7, 3)
The quotient is 2 and the remainder is 1
For ldiv(7, -3)
The quotient is -2 and the remainder is 1
For ldiv(-5, 3)
The quotient is -1 and the remainder is -2
For ldiv(7, 7)
The quotient is 1 and the remainder is 0
For ldiv(7, 0)
The quotient is -1 and the remainder is 7
Explanation:
In the last example (ldiv(7,0)) the denominator is zero, the behavior
is undefined.
Allocates memory.
<stdlib.h>
void *malloc(size_t size);
size
Returns a pointer to the allocated space if successful; otherwise,
returns a null pointer.
malloc does not initialize memory it returns.
#include <stdio.h>
#include <stdlib.h> /* for malloc, free
int main(void)
{
}
Output:
Memory allocated
Memory freed
long *i;
if ((i = (long *)malloc(50 * sizeof(long))) ==
else
{
}
printf("Cannot allocate memory\n");
printf("Memory allocated\n");
free(i);
printf("Memory freed\n");
NULL)
number of characters to allocate
/* for printf, sizeof, */
/* NULL
© 2008 Microchip Technology Inc.
*/
*/

Related parts for SW006014