LabWindows/CVI

Table of Contents
  • LabWindows/CVI Fundamentals
  • Creating Applications
  • Distributing Applications
  • Library Reference
  • Programmer Reference
  • Hardware Information

fopen

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

Purpose

Opens the specified file according to the designated mode. If successful, fopen returns a pointer to the opened stream. When an error occurs, fopen returns NULL and sets errno to a nonzero value.

Parameters

Input
Name Type Description
fileName const char [] Specifies the name of the file to open. Relative pathnames are valid only if relative to the current working directory.
Note Note  Pathnames including backslashes should replace each single backslash with a double backslash to avoid delimiter collision.
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.

Return Value

Name Type Description
stream FILE * Contains a pointer to the I/O stream associated with the opened file when the file is successfully opened. When an error occurs, 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

Examples

Refer to the following examples that use the fopen function:

  • udp\DNSResolver.cws

    Open example
  • userint\custctrl\cviogl\ogldemo.cws

    Open example

Log in to get a better experience