Standard c I/O fopen () Functions

Source: Internet
Author: User

Fopen

Syntax:

  #include <stdio.h>  FILE *fopen( const char *fname, const char *mode );

Fopen () functionFname(File Name) specifies the file and returns a stream associated with the file. If an error occurs, fopen () returns NULL.Mode(Method) is used to determine the purpose of the file (for example, used for input, output, and so on)

Mode) Meaning
"R" Open a text file for reading
"W" Create a text file for writing
"" Attach to a text file
"Rb" Open a binary file for reading
"WB" Create a binary file for writing
"AB" Attaches to a binary file
"R +" Open a text file for reading/writing
"W +" Create a text file for reading/writing
"A +" Open a text file for reading/writing
"RB +" Open a binary file for reading/writing
"WB +" Create a binary file for reading/writing
"AB +" Open a binary file for reading/writing

Example:

    char ch;    FILE *input = fopen( "stuff", "r" );    ch = getc( input );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.