
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Difference Between Files Written in Binary and Text Mode in C++
Text mode | Binary mode |
---|---|
In text mode various character translations are performed i.e; “\r+\f” is converted into “\n” |
In binary mode, such translations are not performed. |
To write in the files: ofstream ofs (“file.txt”); Or ofstream ofs; ofs.open(“file.txt”); |
to write in the files: ofstream ofs(“file.txt”,ios::binary); or ofstream ofs; ofs.open(“file.txt”, ios::binary); |
To add text at the end of the file: Ofstream ofs(“file.txt”,ios::app); or ofstream ofs; ofs.open(“file.txt”, ios::app); |
To add text at the end of the file: Ofstream ofs(“file.txt”,ios::app|ios::binary); or ofstream ofs; ofs.open(“file.txt”, ios::app|ios::binary); |
To read files: ifstream in (“file.txt”); or ifstream in ; in.open(“file.txt”); |
To read files: ifstream in (“file.txt”, ios::binary); or ifstream in ; in.open(“file.txt”, ios::binary); |
Advertisements