Тёмный
No video :(

38 File handling in C++ | C++ Programming Tutorial for beginners | cpp | C plus plus 

tech fort
Подписаться 10 тыс.
Просмотров 38
50% 1

#File Handling:
- File represents storage media for storing data/information.
- Streams refer to sequence of bytes.
- In Files we can store data i.e. text or binary data permanently and use these data to read or write in the form of input output operations by transferring bytes of data. So we use the term File Streams(File handling).
We have to use the header file fstream
- till today, we have been using the iostream standard library, which provides cin and cout methods for reading from standard input and writing to standard output respectively.
- to read and write from a file, this requires another standard C++ library called fstream, which defines three new data types −
- ofstream
This data type represents the output file stream and is used to create files and to write information to files.
- ifstream
This data type represents the input file stream and is used to read information from files.
- fstream
This data type represents the file stream generally, and has the capabilities of both ofstream and ifstream which means it can create files, write information to files, and read information from files.
To perform file processing in C++, header files iostream and fstream must be included in your C++ source file.
- creating a file
- opening a file
- write content to a file
- reading content
- updating
- closing
#Creating/opening a file:
-------------------------
- We can create/open a file by providing new path of the file and mode of operation.
- Syntax for file creation:
FilePointer.open("path",ios::mode);
Ex:
- Open a file for writing
fp.open("D:\demo.txt",ios::out);
- Open a file for reading
fp.open("D:\demo.txt",ios::in);
- Open a file for appending
fp.open("D:\demo.txt",ios::app);
- Open a file for truncating
fp.open("D:\demo.txt",ios::trunc);
Programmatic Example to create/open and file and write some data to a file:

Опубликовано:

 

5 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии    
Далее
8 DBMS SQL  2020 06 14 09 20 24
1:19:35
Просмотров 138
why do header files even exist?
10:53
Просмотров 399 тыс.
I've been using Redis wrong this whole time...
20:53
Просмотров 356 тыс.
Brutally honest advice for new .NET Web Developers
7:19
10 DBMS SQL | Structured Query Language
26:22