SW006014 Microchip Technology, SW006014 Datasheet - Page 66

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 62
freopen
Description:
Include:
Prototype:
Arguments:
Return Value:
Remarks:
Example:
fscanf
Description:
Include:
<stdio.h>
FILE *freopen(const char *filename, const char
*mode, FILE *stream);
filename
mode
stream
Returns a pointer to the new open file. If the function fails a null pointer
is returned.
The function closes the file associated with the stream as though
fclose was called. Then it opens the new file as though fopen was
called. freopen will fail if the specified stream is not open. See fopen
for the possible types of file access.
#include <stdio.h> /* for fopen, freopen, */
int main(void)
{
}
Output:
afile1 was opened
afile2 was opened
Explanation:
This program uses myfile2 to point to the stream when freopen is
called so if an error occurs, myfile1 will still point to the stream and
can be closed properly. If the freopen call is successful, myfile2 can
be used to close the stream properly.
Scans formatted text from a stream.
<stdio.h>
Reassigns an existing stream to a new file.
FILE *myfile1, *myfile2;
int y;
if ((myfile1 = fopen("afile1", "w+")) == NULL)
else
{
}
printf("Cannot open afile1\n");
printf("afile1 was opened\n");
if ((myfile2 = freopen("afile2", "w+",
{
}
else
{
}
printf("Cannot open afile2\n");
fclose(myfile1);
printf("afile2 was opened\n");
fclose(myfile2);
myfile1)) == NULL)
name of the new file
type of access permitted
pointer to the currently open stream
/* printf, fclose,
/* FILE, NULL
© 2008 Microchip Technology Inc.
*/
*/

Related parts for SW006014