Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
22 views

Programming Languages Unit - V

The document discusses file management in C programming. It explains that fopen() is used to open a file and can open it for reading, writing, or both. It also creates the file if it does not exist. Fclose() is used to close the file and release memory. Getc() reads a single character from a file that has been opened in read mode.

Uploaded by

Vinoth Kumar M
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Programming Languages Unit - V

The document discusses file management in C programming. It explains that fopen() is used to open a file and can open it for reading, writing, or both. It also creates the file if it does not exist. Fclose() is used to close the file and release memory. Getc() reads a single character from a file that has been opened in read mode.

Uploaded by

Vinoth Kumar M
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 23

PROGRAMMING LANGUAGES

UNIT - V
• FILE MANAGEMENT
SYNTAX:
FILE *pointer variable;
Pointer variable = fopen(“fileopen” , “mode”);
• C fopen
• C fopen is a C library function used to open an
existing file or create a new file.
Mode Description
r Open the file for reading only
w Open the file for Write only
r+ Open the file for reading and
Writing
W+ Open for reading and writing and
create the file if it does not exist.
If the file exists then make it
blank.
• fclose()
• fclose() function is C library function and it's
used to releases the memory stream, opened
by fopen() function.
• The above example will create a file
called fileName.txt.
• The w means that the file is being opened for
writing, and if the file does not exist then the
new file will be created.
• The fprintf function writes Sample Texts text
to the file.
• The fclose function closes the file and releases
the memory stream.
• getc() function is the C library function, and
it's used to read a character from a file that
has been opened in read mode
by fopen() function.

You might also like