1 00:00:00,280 --> 00:00:07,410 We are having a look in the files in C++, which is somewhat advanced topic, and we deep dive into 2 00:00:07,410 --> 00:00:08,010 it right now. 3 00:00:08,460 --> 00:00:08,970 Let's go. 4 00:00:09,930 --> 00:00:14,010 So you know, what is the necessity of using a file, right? 5 00:00:14,460 --> 00:00:20,190 So we are actually interested in a storage medium for storing our data. 6 00:00:20,200 --> 00:00:25,860 So it's like examples are like we have taxpayers where we stored our text data. 7 00:00:26,070 --> 00:00:33,780 We have our document files, which we are using to create out, like using Microsoft word and stuff 8 00:00:33,780 --> 00:00:34,260 like that. 9 00:00:34,500 --> 00:00:42,480 We create work files or document files where we store both text, images and data like that and a lot 10 00:00:42,480 --> 00:00:44,610 of other kinds of files out of there, right? 11 00:00:44,820 --> 00:00:51,890 This presentation is an example for a file and Excel spreadsheets, which is also an example for file. 12 00:00:52,170 --> 00:00:58,740 But in all where C++ was prevalent, there are mainly two types of files. 13 00:00:59,190 --> 00:01:04,710 One must be files or text players, which we use to store that external data. 14 00:01:05,070 --> 00:01:05,460 OK. 15 00:01:05,670 --> 00:01:11,260 And another one was binary files, which we use to store like bytes of data. 16 00:01:11,280 --> 00:01:16,800 It's also similar to text files, but the data format is stored at by another. 17 00:01:17,040 --> 00:01:17,400 OK. 18 00:01:17,520 --> 00:01:19,530 What is binary zeros and ones? 19 00:01:19,620 --> 00:01:19,980 OK. 20 00:01:20,580 --> 00:01:28,950 So in order to handle C++ files or files in C++, we can create files in C++. 21 00:01:29,190 --> 00:01:31,050 We can all but the files. 22 00:01:31,050 --> 00:01:33,650 We can write data and do it, and we can close that. 23 00:01:33,930 --> 00:01:36,780 So that is the main process is right. 24 00:01:37,620 --> 00:01:41,250 Like we are concerned while we are using files in C++. 25 00:01:41,440 --> 00:01:50,970 So usually for creating files we use like our software such as not bad word bad data like that, right? 26 00:01:51,210 --> 00:01:57,330 But in this case, we can programmatically create files using C++ programming language. 27 00:01:57,480 --> 00:02:01,500 And in this topic, we are excitedly going to learn that. 28 00:02:01,740 --> 00:02:05,340 So in order to learn that some key terms you have to understand. 29 00:02:05,670 --> 00:02:15,780 One is file streams are file handling it, just like writing the file reading from the file or doing 30 00:02:15,780 --> 00:02:19,410 operations in that file or creating file deleting file. 31 00:02:19,560 --> 00:02:23,100 Everything comes under the file stream handling our file. 32 00:02:23,700 --> 00:02:24,150 OK. 33 00:02:24,390 --> 00:02:30,660 And in order to handle files in C++, we use the header file quite extreme. 34 00:02:30,960 --> 00:02:31,410 OK. 35 00:02:31,590 --> 00:02:39,780 And there are a lot of objects or classes inside the extreme darknet chatter file, which will consider 36 00:02:39,900 --> 00:02:44,010 a lot of functions necessary for handling these files. 37 00:02:44,130 --> 00:02:46,050 And we can learn about that. 38 00:02:46,260 --> 00:02:48,360 So one of is offspring. 39 00:02:48,630 --> 00:02:52,320 It's actually useful for writing two files. 40 00:02:52,590 --> 00:03:00,900 So if I want to write that way, if you have the use object straw objects off all steam class and in 41 00:03:00,900 --> 00:03:05,220 order to read the data from if I use, I have stream class. 42 00:03:05,580 --> 00:03:12,540 And if you want to do both at the same time, you want to write the data to a file and read the data 43 00:03:12,540 --> 00:03:13,350 from this file. 44 00:03:13,470 --> 00:03:15,060 Then you use the class card. 45 00:03:15,310 --> 00:03:15,870 Interesting. 46 00:03:16,170 --> 00:03:16,650 OK. 47 00:03:17,670 --> 00:03:25,680 Now these are the main things which we should do, or we should consider while creating a file with 48 00:03:25,830 --> 00:03:26,700 C++. 49 00:03:26,880 --> 00:03:28,230 It's not a simple thing. 50 00:03:28,470 --> 00:03:30,540 We have several steps to do that. 51 00:03:30,750 --> 00:03:31,170 OK? 52 00:03:31,440 --> 00:03:37,650 First step is all putting it by before reading or writing to a file. 53 00:03:37,660 --> 00:03:40,830 We need to open the van in that graph again. 54 00:03:40,830 --> 00:03:41,510 You set it up. 55 00:03:41,670 --> 00:03:43,610 It's very easy to open up, right? 56 00:03:43,800 --> 00:03:46,660 We are seeing the file as I visualized form. 57 00:03:46,680 --> 00:03:52,320 So you are you can just double click on the icon of that file, then the fly at all times and you can 58 00:03:52,320 --> 00:03:52,920 see the file. 59 00:03:53,400 --> 00:03:59,040 That's very straightforward and simple, but we are doing this programmatically meaning to open that 60 00:03:59,040 --> 00:04:00,270 file programmatically. 61 00:04:00,450 --> 00:04:05,250 And in order to do that, we have several programmatic courts. 62 00:04:05,280 --> 00:04:05,700 OK. 63 00:04:05,880 --> 00:04:12,150 So we can go to the steps first and then the detailed steps later. 64 00:04:12,510 --> 00:04:16,710 So first step is opening your file, then you can read and write to. 65 00:04:17,280 --> 00:04:23,250 OK, after that file is all funding the program, you can read from the file or right through that file. 66 00:04:23,370 --> 00:04:25,170 Then you need to close the file. 67 00:04:25,200 --> 00:04:26,760 That's the final steps. 68 00:04:26,910 --> 00:04:32,970 So these are the important steps which we need to do while we have to create that fire. 69 00:04:33,030 --> 00:04:36,180 So now let's see each step in the update. 70 00:04:36,630 --> 00:04:37,920 So opening your file? 71 00:04:38,040 --> 00:04:38,370 Right? 72 00:04:38,580 --> 00:04:47,670 I have already discussed that either let off steam or steam object can be used to open a file for writing. 73 00:04:48,030 --> 00:04:48,480 OK. 74 00:04:48,690 --> 00:04:56,310 And if stream object is used to open a file for reading purposes, if steam can only open the file for 75 00:04:56,310 --> 00:04:56,730 reading. 76 00:04:56,940 --> 00:04:59,670 But if you want to open the file for writing. 77 00:05:00,230 --> 00:05:08,060 Use both of Timor F Street now, how you get one of the file that is used to buy a function, call all. 78 00:05:08,690 --> 00:05:09,080 OK. 79 00:05:09,380 --> 00:05:13,910 And it's a member of extreme, extreme and off stream objects. 80 00:05:14,060 --> 00:05:14,690 OK. 81 00:05:14,870 --> 00:05:20,990 This function is I like get we are getting this function from the extreme garbage header file. 82 00:05:21,210 --> 00:05:22,820 And how are you going to do that? 83 00:05:23,150 --> 00:05:25,580 This indexes void or. 84 00:05:26,210 --> 00:05:33,120 Then on the bracket, you have to specify the file name, then how you want to burn that file. 85 00:05:33,140 --> 00:05:37,900 So this is debris dot symbol, right? 86 00:05:38,300 --> 00:05:40,520 Or Pan Maude Maude. 87 00:05:41,420 --> 00:05:48,590 This one is called file or binary, more so we will be discussing that right now in the next slide. 88 00:05:48,830 --> 00:05:57,770 So how you can use this iOS Dot Dot or by more more, then that's actually very useful for you to know 89 00:05:57,770 --> 00:06:06,500 how what are the different ways you can find and this opening more chapter opening your file in different 90 00:06:07,220 --> 00:06:07,880 manners? 91 00:06:08,030 --> 00:06:11,630 OK, see here to have that march off opening. 92 00:06:12,350 --> 00:06:21,140 So again, if you are opening your file in iOS app more, then that discard app and more so if you open 93 00:06:21,140 --> 00:06:24,870 a file, walked all things you right into that fight. 94 00:06:25,130 --> 00:06:27,410 It will be appended to the end of the file. 95 00:06:27,890 --> 00:06:34,520 See, the other line is you will not be able to see the file like in a graphical user interface. 96 00:06:34,760 --> 00:06:40,310 So why do you need to do is like you need to specify how you want to use the file in your program. 97 00:06:40,490 --> 00:06:45,170 So in order for that, you have different types of modes of operating a file. 98 00:06:45,380 --> 00:06:47,270 And those are specified all here. 99 00:06:47,420 --> 00:06:53,270 And if it is an app and more water things you write into that file, it will be appended to the end 100 00:06:53,300 --> 00:06:57,020 of the event in order to help you understand this topic. 101 00:06:57,310 --> 00:07:03,680 I'm actually going to flag different find for getting the pen. 102 00:07:04,160 --> 00:07:09,710 And suppose you have a file and daddy, you have this particular thing written. 103 00:07:11,410 --> 00:07:15,760 Welcome to my new file. 104 00:07:16,030 --> 00:07:22,930 This was the content of the fight, and if I'm opening the fight in a pen more, then what are things 105 00:07:22,930 --> 00:07:24,010 you put into the fire? 106 00:07:24,040 --> 00:07:30,040 Later, it will be come after that last portion of the fair, which means after this new. 107 00:07:30,370 --> 00:07:38,080 So if I'm adding a few more lines, why this is getting added at the end, because you have opened the 108 00:07:38,230 --> 00:07:47,650 firing at Benmore, then you have 80 more, which is actually putting a file for moving the read or 109 00:07:47,650 --> 00:07:49,340 write and burn for the end of the file. 110 00:07:49,360 --> 00:07:53,620 So this is all just similar to a more like you can do both. 111 00:07:53,650 --> 00:07:57,100 You can read from the end or write end. 112 00:07:57,790 --> 00:08:04,720 And if you want to just open the file for a file for reading reading only, then you can use Enameled. 113 00:08:05,050 --> 00:08:09,670 And if you want to open a file for writing early, then you can use out more. 114 00:08:10,000 --> 00:08:17,800 And if the fire is already there and you want to believe that file with that very same name, right? 115 00:08:18,070 --> 00:08:25,830 But you want to believe that file and create a new file with that same name, then you have to use more. 116 00:08:26,080 --> 00:08:28,360 So suppose this is my file called. 117 00:08:30,530 --> 00:08:31,580 My final. 118 00:08:32,690 --> 00:08:34,760 Not ESD. 119 00:08:35,150 --> 00:08:38,780 This is my file, and this is my file with this gunman. 120 00:08:38,990 --> 00:08:47,000 And I want to be need all the amendments inside this my pilot and add everything from the beginning. 121 00:08:47,240 --> 00:08:49,670 Then I will be using try and get more.