SW006013 Microchip Technology, SW006013 Datasheet - Page 69

MPLAB C Compiler For DsPIC DSCs

SW006013

Manufacturer Part Number
SW006013
Description
MPLAB C Compiler For DsPIC DSCs
Manufacturer
Microchip Technology
Series
DsPIC30F/33Fr
Type
MPLAB® C Compilerr
Datasheet

Specifications of SW006013

Supported Families
DsPIC30F, DsPIC33F
Core Architecture
DsPIC
Kit Contents
Software And Docs
Mcu Supported Families
DsPIC30F And DsPIC33F
Tool Function
Compiler
Tool Type
Compiler
Processor Series
dsPIC
Lead Free Status / RoHS Status
na
For Use With/related Products
dSPIC DSCs
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
© 2008 Microchip Technology Inc.
fseek (Continued)
fsetpos
Description:
Include:
Prototype:
Arguments:
Return Value:
Remarks:
}
Output:
"This is the beginning"
"this is the middle and this is the end."
"this is the end."
Explanation:
The file afile.out is created with the text, “This is the beginning, this
is the middle and this is the end”.
The function fseek uses an offset of zero and SEEK_SET to set the file
pointer to the beginning of the file. fgets then reads 22 characters
which are “This is the beginning”, and adds a null character to the
string.
Next, fseek uses an offset of two and SEEK_CURRENT to set the file
pointer to the current position plus two (skipping the comma and
space). fgets then reads up to the next 70 characters. The first 39
characters are “this is the middle and this is the end”. It stops when it
reads EOF and adds a null character to the string.
FInally, fseek uses an offset of negative 16 characters and SEEK_END
to set the file pointer to 16 characters from the end of the file. fgets
then reads up to 70 characters. It stops at the EOF after reading 16
characters “this is the end”. and adds a null character to the string.
Sets the stream's file position.
<stdio.h>
int fsetpos(FILE *stream, const fpos_t *pos);
stream
pos
to fgetpos
Returns 0 if successful; otherwise, returns a non-zero value.
The function sets the file-position indicator for the given stream in *pos
if successful; otherwise, fsetpos sets errno.
}
y = fseek(myfile, -16L, SEEK_END);
if (y)
else
{
}
fclose(myfile);
perror("Fseek failed");
fgets(s, 70, myfile);
printf("\"%s\"\n", s);
target stream
position-indicator storage as returned by an earlier call
DS51456E-page 65

Related parts for SW006013