From 76f416935be8f7470637f7f8ee01bf078084e4b8 Mon Sep 17 00:00:00 2001 From: Chase <44284917+TotallyNotChase@users.noreply.github.com> Date: Sat, 17 Nov 2018 23:44:58 +0530 Subject: [PATCH] Added modes for file handling in index.md (#21902) Added different modes that can be used and their description under "The Real Deal" Section. --- guide/english/c/file-handling/index.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/guide/english/c/file-handling/index.md b/guide/english/c/file-handling/index.md index dbc06907d04..8fbeb342d50 100644 --- a/guide/english/c/file-handling/index.md +++ b/guide/english/c/file-handling/index.md @@ -168,6 +168,32 @@ The above methods only worked for the most basic of cases. If you wanted to do To accomplish this, you will use a function called `fopen`. This function takes two string parameters, the first being the file name and the second being the mode. Mode is basically permissions, so `r` for read, `w` for write, `a` for append. You can also combine them, so `rw` would mean you could read and write to the file. There are more modes, but these are the most used. +There are a number of modes that can be used for file handling. + +**"r"** **-** **Open file for reading** + +**rb** **-** **Open file for reading in binary mode** + +**w** **-** **Open file for writing** + +**wb** **-** **Open file for writing in binary mode** + +**a** **-** **Open file for appending** + +**ab** **-** **Open file for appending in binary mode** + +**r+** **-** **Open file for both reading and writing** + +**rb+** **-** **Open file for both reading and writing in binary mode** + +**w+** **-** **Open file for both writing and reading** + +**wb+** **-** **Open file for both writing and reading in binary mode** + +**a+** **-** **Open file for both reading and appending** + +**ab+** **-** **Open file for both reading and appending in binary mode** + After you have a `FILE` pointer, you can use basically the same IO commands you would've used, except that you have to prefix them with `f` and the first argument will be the file pointer. For example, `printf`'s file version is `fprintf`.