C++ file handling for beginners! The easiest way to read/write into text files!

CodeBeauty
Youtube
Related Topic
:- programming skills Programming Langauge Basic Language Requirement: Python. C language C++ language

Files are used to store data permanently. In this video, you'll learn how to read and write into text files using C++. In order to work with files, first, include the fstream library. Inside this library there are three data types: ofstream - used for writing into files ifstream - used for reading from files fstream - used for both read and write In this video, I'm demonstrating the use of fstream object in file handling. In order to open a file we use open() function. This function receives two parameters: file name and file open mode. The modes in which file can be opened are below: ios::in - opens the file to read(default for ifstream) ios::out - opens the file to write(default for ofstream) ios::binary - opens the file in binary mode ios::app- opens the file to append new info at the end ios::ate - opens and moves the control to the end of the file ios::trunc - removes the data in the existing file ios::nocreate - opens the file only if it already exists ios::noreplace - opens the file only if it doesn't already exist We can also combine different modes using symbol | For example: myFile.open(“saldinaFile.txt”, ios::out | ios::in); In this example, we are opening saldinaFile.txt for both writing and reading. Create Modern Apps, 5x faster, with less code, Download FREE C++Builder Trial: https://bit.ly/CppBuilderFree I recently created the option for you to buy me a coffee/cookie, so if you enjoy my content and find it useful consider that small gesture of gratitude for all the hard work that I put into these videos. That would mean a lot to me!https://bit.ly/CodeBeauty_BuyMeACoffee Of course, don't feel pressured if you can't, I will continue posting free educational content for you nevertheless. Contents: 00:00 - Intro 01:12 - Write into a text file using C++ 07:56 - Append to a text file using C++ 10:45 - Read from a text file using C++ 16:06 - Tasks to test your C++ knowledge! Task 1. ASCII Table video: http://bit.ly/asciiTable Task 2. Structures video: https://bit.ly/structuresVideo Tag me on you Instagram stories: Instagram - https://www.instagram.com/TrueCodeBeauty Twitter- https://twitter.com/TrueCodeBeauty

Comments