SW006014 Microchip Technology, SW006014 Datasheet - Page 64

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 60
fread
Description:
Include:
Prototype:
Arguments:
Return Value:
Remarks:
Example:
Reads data from the stream.
<stdio.h>
size_t fread(void *ptr, size_t size, size_t nelem,
FILE *stream);
ptr
size
nelem
stream
Returns the number of complete elements read up to nelem whose
size is specified by size.
The function reads characters from a given stream into the buffer
pointed to by ptr until the function stores size * nelem characters
or sets the end-of-file or error indicator. fread returns n/size where n is
the number of characters it read. If n is not a multiple of size, the value
of the last element is indeterminate. If the function sets the error indica-
tor, the file-position indicator is indeterminate.
#include <stdio.h> /* for fread, fwrite,
int main(void)
{
}
FILE *buf;
int x, numwrote, numread;
double nums[10], readnums[10];
if ((buf = fopen("afile.out", "w+")) != NULL)
{
else
for (x = 0; x < 10; x++)
{
}
numwrote = fwrite(nums, sizeof(double),
printf("Wrote %d numbers\n\n", numwrote);
fclose(buf);
printf("Cannot open afile.out\n");
nums[x] = 10.0/(x + 1);
printf("10.0/%d = %f\n", x+1, nums[x]);
pointer to the storage buffer
size of item
maximum number of items to be read
pointer to the stream
/* printf, fopen, fclose, */
/* sizeof, FILE, NULL
10, buf);
© 2008 Microchip Technology Inc.
*/
*/

Related parts for SW006014