LabWindows/CVI

Content Type
Programming Language
Current manual
Table of Contents

freopen

FILE *freopen (const char fileName[], const char mode[], FILE *oldStream);

Purpose

Does the following:

  • Attempts to close the file that is associated with oldStream—failure to close the file successfully is ignored
  • Opens a file and associates it with the I/O stream that is pointed to by oldStream
  • Clears error and end-of-file indicators for the I/O stream
Note Note  This function is useful for redirecting the standard streams (stdin, stdout, stderr) to a file.

If the open operation fails, fopen returns NULL and sets errno to a nonzero value.

Parameters

Input
Name Type Description
fileName const char [] Specifies the name of the new file that is opened. The I/O stream associated with oldStream is associated with this file.
mode const char [] Specifies the mode of reading and writing for the opened file. The possible modes are listed in the following chart:
Mode
argument
Description
r Open text file for reading.
w Truncate to zero length or create text file for writing.
a Append; open or create text file for writing at end-of-file.
rb Open binary file for reading.
wb Truncate to zero length or create binary file for writing.
ab Append; open or create binary file for writing at end-of-file.
r+ Open text file for reading and writing.
w+ Truncate to zero length or create text file for reading and writing.
a+ Append; open or create text file for reading and appending.
rb+ Open binary file for reading and writing.
wb+ Truncate to zero length or create binary file for reading and writing.
ab+ Append; open or create binary file for reading and appending.
oldStream FILE * Contains a pointer to the I/O stream that is redirected. The file formerly associated with this stream is closed if possible.

Return Value

Name Type Description
newStream FILE * Contains a pointer to the new I/O stream associated with the opened file if successful. If the open operation fails, fopen returns NULL and sets errno to a nonzero value.

Additional Information

Library: ANSI C Library

Include file: ansi_c.h

LabWindows/CVI compatibility: LabWindows/CVI 3.0 and later

Was this information helpful?

Previous

free

Next

frexp

Previous

free

Next

frexp

Log in to get a better experience

Help us improve your future ni.com experience.

Did you find the documentation you were looking for?

Submit