Modes for Operating a File in C

Mode Description
“r” Opens a file for reading
“w” Creates a file for writing or truncate to zero length
“a” Opens a file for writing at end or create for writing
“r+” Opens an existing file for reading/writing
“w+” Truncates to zero length or create file for updating
“a+” Opens for updating at end
“rb” Opens a binary file for reading
“wb” Opens a binary file for writing
“ab” Opens a binary file for writing at end
“rb+” Opens an existing binary file for reading/writing
“wb+” Creates a binary file for updating/writing
“ab+” Opens a binary file for appending at end

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.