Hang on to your pantaloons, my friends, because we are about to get into 20 of the best products from the drugstore in 20 different categories, from 20 different brands, in hopefully under 20 minutes. Let's get going. Hello my friends, we're going to be doing that video today. I'm so excited because Andrea Matelano, who I absolutely love and I watch all the time, she did this video, she got her idea from Kelly Gooch. But you know what, I remember this video kind of going around a really long time ago from Jen Love's reviews. I know that's not her name now anymore, but this video has been around for a while. I did it at the time, but you know, things change after two years, so we're going to do it now.  So if you want to skip over this part, the timestamp is right here where you can start into the products. Now, I am today wearing a really fun T-shirt. It is just one of my favorites because it has this inset lace detail, but the lace is so pretty on it. This comes in a bunch of different colors and it's very true to size. I wear my clothes just a little bit tighter when I wear a T-shirt like this, because if I get them too big, then they're too sloppy in the shoulders and whatnot. So I do wear a large, and this is pretty true to size, as you can see here in the picture, I'm showing you the full length. And as always, I do love to show you my jewelry as well.  So pretty. And I did put on two layered bracelets today. So I will make sure I put that for you. My rings, my fingernail polish, and all the makeup I'm wearing is actually in the video today so that you know that I will right here as always, I will put a number that will correspond to whatever product I am holding up. You don't have to remember the name or the color of that product. You just have to remember the number that goes up on the screen. Then open up the description box right below this video and go and look for that number. Next to that number will be the product, the color that I wear, and the link to that product if you'd like to shop that way. So this is 20 products from 20 different brands in 20 different categories.  I'm just gonna go in the order of what's in front of me so that you guys can see that. Now in thinking about where I would put color pop in this, I had to put color pop for their eyeshadows. So color pop is the number one. Here is the Stone Cold Fox Palette. I'm pretty sure most of you have seen this a million times. But to me, this is the most fantastic neutral tone palette that you could possibly get because not only do you have the very, very neutral browns, but you have warm browns as well. You have a little bit of warm, kind of on the side of rose colors in here or rose shades. You have the grays and then you have those very grayish neutral browns and they are fabulous. That's why I put color pop in this category because I absolutely love their pressed shadows. Okay, this one is the Lust for Desk. This is a neutral outside the box palette. So this palette I actually reach for so very much and it is what I have on my eyes today. I reach for this palette all the time because to me it has enough of pop of colors that you're gonna brighten up your look, but you're also getting a beautiful amount of shimmers that are just gorgeous across eyelids and then you're getting these buttery mattes in all different shades. You're getting lighter ones and you're getting deeper ones. And I just think that this one would work for so many people. A lot like the Stone Cold Fox. Only like this is a step above because the colors are just a little bit bolder, a little bit brighter and it's not just neutral shades. And I absolutely love this one too. So they have the small, the medium and then this is the nine-pan. This is the last one. This is All Amethyst. Yes, I did pick three and cheated on this, but it's my channel. So, you know, sue me. I love this one because I finally found my favorite purple eyeshadow palette because it has so many different colors of purple in it that you can go neutral if you want to. You can go pop of color if you want to. You can go super high pigment and you can go very muted, deep smoky. I think this palette is fantastic and there's so many looks that can come out of it. All right, next I picked a highlighter from Catrice. I was gonna pick their foundation. I love their foundation, but this highlighter is one that really, I loved it for a long time. This is more than a glow highlighter from them. It feels like a very creamy formula. However, it is a powder formula. There is absolutely no sparkle in that in this and it's called Supreme Rose Beam. This is such an intense, beautiful highlighter and I love wearing it. I have it on underneath my blush today and I just think it's one of those highlighters that you can really sheer it out and make it look just like a really soft glow or you can just really, you know, make it bright, wear it on your eyelids if you want to. It's just so beautiful and the formula can't be beat. All right, next primer was a hard one for me, but I have been reaching for the Elf Power Grip Primer for such a long time. I love this primer. It goes on your face and leaves your face just a little bit tacky, which in turn will grab onto that primer for the day or I'm sorry, grab onto that foundation for the day and then you have your foundation on all day long. Now, I don't really feel like this is super blurring. However, I do feel like my makeup does look perfected after I use this. This is such a good one and I think that anybody that has problems with their foundation sliding off with regular primers that have dimethicone in it that they should try this one. Now, the mascara that I chose from Essence is not going to be any surprise to any of you. I've done a whole video dedicated just to this mascara that this mascara wipes out every high-end mascara I've ever used. This is the 24 Ever Bold Volume Mascara from Essence. I love the silicone brush on it. I don't know why, but for some reason, this seems to give me the longest lashes ever. I think that it's because of not just the formula is so good, but the bristles on this are super short and they're super tight together. So it kind of acts like a hybrid between the brushes that have the natural bristles on them and the synthetic ones. So I do love this. And again, forgive me. I'm having a really hard time today with my shaking. So the palsies out of control, but the products are really good. Foundation is one that I could have gone with so many brands, but after rediscovering this one, I had to say that this is my number one favorite foundation from L'Oreal. This is the L'Oreal Pro Glow Infallible Foundation.  It's just as good. But for me with my hyper-dry skin, the Pro Glow is fantastic. To me, this is a dupe for the Estee Lauder Futurist. It's better than the Charlotte Tilbury Beautiful Skin. I like it better than the It's CC Cream. I mean, this checks off so many boxes for me, covers beautifully, doesn't show texture, doesn't show pores, fine lines, wrinkles. I think that this foundation works for so many women so well. And like I said, if for some weird tense that it doesn't work for you, as a mature woman, try the Matte. You might really love that. Absolutely over-the-top beautiful on mature skin. Actually, any skin, I would really think so. The number seven, Lift and Luminate Powder. Now, I have mine in light, which is just almost too light while I'm self tanning, but the powder in here is magical. It is so much better than Charlotte Tilbury's Airbrushed Powder. I know that I might have some people argue with me on that, but I feel like this is so much lighter and airy, and it just does not feel like a powder on my skin. I reach for this to set my under eyes. I reach for it to do the creases around my nose and my chin. I also reach for it as a blurring powder to finish my makeup and set down any of those parts that really rub off very quickly, like the bottom of your chin. This is an incredible powder, and I swear, if you haven't tried it and you like the Charlotte Tilbury, I think you will be very impressed when you try this one. Let's just stay with powders. Physician's Formula is my next brand, and I chose the Physician's Formula Rose All Day Set and Glow. Now, this part right here, which is the glow part, this is kind of a sticky glow part. I actually use that just for a kind of a lip gloss, which is fine. I don't really use that, but what's in here as far as that powder goes is incredibly beautiful. If you love the Hourglass Ambient Setting powders, this is almost just a tiny bit more glowy than those, but it's darn close, and I did use this. So you can see it on my finger right there. It doesn't really have much of a glow at all, maybe a tiny bit, but it's more of that lit within ambient look that Hourglass boasts as well. It's so pretty, and I did dust this all over my face just to give that glow right in the center part. It comes in this color, which is luminous light, and then it comes in the rose color, the actual rose color, and the rose is really brightening if you have fair skin. Very brightening, very pretty. This one I would say is just a tiny bit more glowy than that original one, just because it is more brightening, but these are beautiful, non-drying, and I love having them, because once Milani's Prep Set and Glow was discontinued, I went straight to those, and I have not regretted it at all. The next one is a product from CoverGirl, and it is the Priming Glow Mist. I chose this one because I was reaching for this one so much lately, instead of my Max 6 Plus to spray on my brushes, and I'm reaching for it to spray on my makeup sponges before I put on my foundation. Now, a lot of people ask me, why do you do that? My makeup sponges are damp when I use them, but I spray this on there right before because it just seems to help spread the foundation out a little bit more cleanly, a little bit more evenly. It's just a practice that I got into a long time ago, and it does seem to make my foundation last longer. Now, this boast said it has cactus water, rose water, vitamin C, no alcohols, hyaluronic acid. It has some really great ingredients in it. It's actually a clean beauty as well, and you know that CoverGirl went cruelty-free a while ago, and I think that's fantastic. Now, one of the products that I have recently discovered that I'm really, really in love with is called Focalore Face, and this is the highlighting contour duo, and this one is in 04, and I think this is a pretty fair one. It's what I have on today as my bronzer and my contour combo. I really think that this is one of the prettiest contours that I have found in a long time because I'm always looking for that barely on the side of muddy, that sounds terrible, but barely on the side of it looking muddy and then barely on the side of it looking warm, and that's what this one gives me, is the perfect color for that. Now, the other side, which is supposed to be highlighting, it's not got any theme in it or anything like that in it, this is more of a powder that just would brighten any area that it went on to because it's so intensely white, and I really love using this on my eyelids when I don't want to use any shimmer because it super brightens that area, so this is a really creamy, beautiful powder, and I have been loving working with it, and I've reached for it a ton since I got it, and even though I absolutely love the cream products that I got from them that I showed in my dupe video the other day, I think that for summer I like the powder a little bit more because nothing's sliding around, like sometimes you have to set cream products down, when you got a powder, you don't have to do that. My next product I was so excited to find because this is from Eco Tools and these are called the Bio Blenders, and I got the Trio, they come in a duo where you can get the two big ones or you can get the Trio with the different sizes, I like having the different sizes, I think this is all kinds of fun, and this actually says right on it, Eco Tools, plant me. If you put this in the ground, it's gonna degrade and it's gonna dissolve, so it's not only just a great sponge, it's good for the environment too because it's going to degrade eventually and go back to the earth, which I think is fantastic. Now, these sponges are super soft and I have loved working with them, but I think the quality of these as far as the softness and how they apply makeup is every bit as nice as the Beauty Blender and any other sponge that I've ever used before. My next brand to talk about is LA Girl and I had to go with their eyeliners because I've recently discovered how phenomenal these are, these are amazing. I have two of the ultimate intense stay matte liners and I have one that is in a teal and then I have another one that is in a purple. Both of these are the best at sticking around, they're so pretty. The teal one I do have on my bottom line smudged out just a little bit today. Then there are these ones that are the shockwave ones. These stay on a long time as well. Again, I have another teal, kind of a little bit more on the blue side on that one and I have this really bright, pretty purple, kind of a medium purple color, so pretty. And then I have one of the most interesting electric blue colors, LA Girl Glide Eyeliner and this is the coolest color. I'll make sure that all these colors are put down below. I love that this is like an electric purple color. I just think it's so pretty. So all of those are fabulous liners. They have this smooth glide to them when you put them on. These two right here that I showed you at the very first, the ones that are the ultimate, those two are gonna last the longest of all of these. I truly love the liquid blushes from Flower Beauty. I think that they are just something so special. I have a mixture of the two of these on my cheeks today as my blush and it just gave this little bit of a bubblegum pink but also a little bit of a muted color to my cheeks. So I'm not gonna smear them together at first. Sorry, I was going to. The bottom color right there is called the Bubbly. That's the bubblegum pink and then cheeky is the top one and that's the one that is just beautiful as kind of your cheeks, but better. We don't hear that term very much, but it really truly is. So what I did was I swirled the two together and I made a custom one that I just, I love today. I think it's so pretty. Because it's a cream formula and it dries down, it's gonna be there for you all day long. I love those blushes and they come in quite a few colors. She just added a few more colors to her line so I was really glad about that. Love those so much. All right, next is from Nyx Cosmetics and this is a product that I talk about rarely but I should talk about it more because if you've been with me any amount of time, you know that the Nyx multi-tasker mixing medium is something very, very special and innovative.  Just stick it in a little bit of primer and your eyeshadow will become very bold and bright. Well, that's what this does but it also makes any of your eyeshadows into an eyeliner. It will make any of your eyeshadows into, I hope you can see that right there, it will make any of your eyeshadows into a matte lipstick if you want it to. You can use it to mix shadows with for blush. You can use it, it's so good.  But let's just pick up this color right here in the middle and it's bright and it's pretty and I will just swatch it right there for you. Pretty, very pretty and but now I'm gonna take that mixing medium and I'm gonna just swat that across. Swatch it across there and I'm gonna pick up that same powder and I'm gonna mix it together and what it's gonna do is not only is it going to change the color so it's a little bit more intense, a little bit more bold, a little bit more bright, it's also not going to wipe away. This would be a great mixer for a loose pigment so that you didn't have a bunch of fallout. If you have a palette that does a bunch of fallout and you're having a hard time with it, you can use this as well. Now, I used a lot, you don't need to use a lot but it will make anything budge-proof. I mean, if you have a wedding to go to, you have something that you have to be there all day long and you don't want your makeup to go anywhere until you take it off with your makeup remover at night, the NYX multi-tasker with whatever color you mix it with is gonna be there. I did just barely put also the Jason Woo eyeshadow primer in one of my Dupes videos for the Anastasia Beverly Hills eyeshadow primer that I love so much. This is a great primer for taking care of any discoloration. It makes your eyeshadow stick to your eyes all day long so if you have any sweating, this is going to help with the creasing and everything that happens with your eyeshadow normally and it's going to make your eyeshadow be really bright and pop. And this one will do you so good for summer so if you're at Target and you see the Jason Woo stand and you can find this one, I did have to order mine. This is a fantastic eyeshadow primer. And then also from Ulta, now you might argue that this is not a drugstore product but it is on the drugstore side of Ulta. From Ulta is their Brow Tint. I have taken to only using this product on my eyebrows. I don't use anything else. I don't fill in anything else. I just use this and this has the itty bitty as little tiny spoolie on it. This one I think is the light one but it really gives that almost laminate effect to the eyebrow hairs that I have. I'm really tongue tied today. I love that I can push up any eyebrow hair and it will stay where it's put. It really does grip onto all of them. It has a little bit of a coating property where it's gonna make them look thicker and fuller and I've just been absolutely loving it. And I even paint right on the skin with this stuff. So this has just been the best of both worlds for me as far as putting down the color and keeping the eyebrows in place. So good, absolutely love this. I think this is Risa Does Makeup's favorite one too. And I also put in that video the Rimmel exaggerate lip liners and I have four colors. The color that I'm wearing together today is called Addiction and I love Addiction. It's just this muted mauve rose color. So beautiful and I'm gonna make sure that is right. Yes, it's Addiction. This next one is called East and Snob. Kind of more of a pinkish one. A muted pink and then the next one is called Enchantment. Enchantment is so pretty. It's more of a brighter pink in that one right there. Kind of not really even a bright pink. Just one that is kind of a rose pink. And then the last one I have is called Innocent. And this is a beautiful nude color. So these are so good for me. I love this formula. I love how long they stay on my lips. I love how I can draw outside the line and it be so pretty. I also absolutely love that they're automatic with the angle on them so that they almost feel like they're sharpening themselves as they go and I get a really beautiful line on my lips every time. So, so good. From Profusion, the Winkett liner. This is so amazing. When I started doing my channel, I experimented with tons of different eyeliners and I found that I could only use a pen liquid felt tip liner on my top line if I wanted to do it because if I tried to use just a dip one or if I tried to use a brush, I seem to just get them always too thick. And then after that, and I figured that out, I was on the hunt for the thinnest one possible. Can you guys see how thin that tip is? It is so tiny. So when I lay that down and I put it just barely into the lash line on the top, it's phenomenal. And I'm gonna have a hard time doing this because my hands are shaky and no steadiness, but it does give the just the thinnest, thinnest line possible. And like this is like 450, I think. So that's pretty darn good to be able to get one. The next brand is Revlon and Revlon was my lipstick brand. And yes, I know you may have thought that Maybelline was going to be my lipstick brand, but I thought let's do something a little bit different. Let's go out on a limb and go wild. Let me swatch these. I think I have four cream and then one that is the matte. This one is called the blush. This is an everyday lipstick for women that just like to have a tiny bit of color. It's a very creamy, very satin lipstick. This one right here is called the Blushing Mob. Little bit more intense of that same one, but with a little bit more coral or peach in it. Still on the rose side. The next one is called Barrett All. So this is kind of along the lines of, this is almost like a balm. Almost this consistency of a balm and just a very natural color on your lips. The next one is Primrose. That's the one that I have on with the liner I have on today. This is a very cool toned pink right there. And when I'm not self tanning, that's pretty bright pink as well. And then the next one is called Make It Pink. And this is the only one that I have that is their mauve formula or mauve formula, matte formula. But these are, their mattes are really super pigmented. So if you wanted to try out the more pigmented ones of these, that would be it. The other ones are super creamy and super great. I love their lipstick. And then for Milani, it had to be for me. I do love so many of Milani's products. This was really hard. But the Keep It Full lip glosses, these are like, these should be award winners in my book. I love these things. They're so pretty. They make me happy just to wear them and just to have them. The first one I have is called Moonlight. It's one that has just a cast of a little bit of shimmer pearl in it. So pretty. And then the next one is Champagne. Is this, nope, this is nude shimmer. I do have the Champagne one somewhere. This is nude shimmer. It just really will brighten up any color that you put on top of it or underneath it. I'm sorry, any color. It will be brightening for any color that you use it on top of. And then the last one, let's see what this one is. This one is called Tropical Shine. And it has a little bit more of that orangey, peachy tone to it. It's what I wore on top of that pink lipstick today. They do have a tiny bit of a, almost a vanilla fragrance in them. So if that bugs you, you might skip over that. They don't really have any taste except for where I can feel kind of the menthol in them. So I love these. They stick around for a long time. They make your pelt look just juicy and lovely. And I have been in love with these for a long time. My other favorites, I love their pink sparkle. There's pink shimmer, I think it is. And then I also love the Champagne one. And then the last brand is Morphe. And I don't normally recommend Morphe at all because there's not very many products in there that I'm really in love with. However, during the summertime, this baby comes out for me and it's their continuous mist. This is a super fine mist setting spray.  You're never ever going to have anything, any droplet looking on your face. And this stuff makes your makeup sit down. And I do want to just disclaimer, yes, this does have alcohol in it, but so does Urban Decay all nighter. And the reason that it just locks makeup in places because of that alcohol. Now, personally, I feel like the best setting thing ever is powder, but to put powder on and then put this in to kind of melt everything together, you're gonna have a pretty budge-proof face of makeup that day. So this is my last product from Morphe. That's my last one that I have to recommend to you. I loved gathering all of these up. This was such a fun video for me to be able to get together for you guys. Hopefully you got some different ideas from this video than I normally do. So what we're gonna do right now is we're going to put up a video right here and I will put up my last one about this. That was 20 products from 20 different brands and 20 different categories. And I'll put that up right here so that you can see that and you can compare it to this one. I hope that you're all happy, healthy. Please come back and visit me very soon again. I love you very much and I will talk to you in my very next video. Goodbye, my friends.


You get out here, plans will change and you need to have an initial plan that has flexibility to. Recognizing this and then trying to take that and learn from it. Started with the narrative, what they want the perception to be and that was challenging. The cognizant of my visual signature, my electromagnetic signature because if I can be sensed, I can be hit. NWX is a large scale force on force exercise designed to operate against a peer competitor in the command and control denied or degraded environment. Our number one focus in the secondary division is being ready for major conventional operations against a peer competitor. Friction, chance, uncertainty, chaos that normally happens in war will happen in this exercise. Simulations can be clean and kind of antiseptic. This will not be anything like that. So with the near peer aspect too that where they didn't abide by all the same conventions, it kind of made us have to be more creative as well and to try to put ourselves in that mindset of how do we think the adversary is gonna act. And so we had to be creative obviously within the Geneva Conventions but that's still allowed us to have a little more flexibility and certainly challenged us. That was supposed to occur fell through. We had a moment where we realized that our orders were no longer valid, that we were staging for assault and we had to really think hard. We collectively as a staff, the operations officer, the intelligence officer, the fire support officer and the air officer had to try and understand what had changed about the situation and what should we actually be doing. It was one of those moments where everything just clicked. Everyone played their role and played it well and we were right. We immediately transitioned to the defense and not too long after that, the enemy conducted a preemptive schooling with that. UX was challenging because you were facing a real adversary that was thinking and reacting just like you were. And so you had to put yourself in their shoes and think how would I react to this and try to figure out what they would be doing to kind of force our hand as well. Like this anywhere else in the Marine Corps, there's no other base that allows you to do the things that you can do out here from a squad level all the way up to regiment conducting the regimental assault corps which really allows you to get a unit that comes out here and succeeds.


So, last time we discussed use of classes in some applications. We specifically looked at the editor application and saw a interesting model where the text to be edited could be kept in two different stacks with an assumed cursor in between. So, if I want to edit a text, I assume a cursor, I move the cursor to some position and I arrange things such that whatever is to the left of the cursor goes into the left stack and whatever is to the right of the cursor goes into the right stack. That makes editing conceptually simpler. Whenever I want to move cursor forward or backward, I effectively pop characters from one stack and push them on to another. If I want to insert something before the cursor, I insert those characters onto the left stack by pushing them in and if I want to delete characters at a cursor position to the left of cursor again, I would just pop characters from the left stack and forget them. What we did was that we implemented the class stack and then used it in our main program for editing. We will extend that model further by first isolating the stack class implementation in a separate file and see how that file could be included in our program. Additionally, we will now define another class called the editor class where the interface functions to the editor could be implemented by us taking cognizance of whatever editor commands we have in mind. We will first define those commands and see how those commands are to be implemented. Then we will isolate the necessary general functions of the editor which are required to do so and we will implement them. We will write the code for them as member functions of the class editor. That way our main program would become much simplified. I also have some very important announcements to make which I will do at the end. First of all, if I define a class stack in a separate file, I could actually call that file as stack dot h. Dot h is a standard header file symbol. Any extension dot h typically means that it contains some headers. Header is not necessarily only text by the way, but header is the nomenclature given to files which will occupy the top position in any program when it is compiled. Essentially, you include header files through a preprocessor command like hash include. We have seen those commands elsewhere. We include the library functions like that. The difference is that the library functions are included at the linking time. Whenever your program is compiled, it is to be linked with the appropriate functions and then you use those library functions. But you could also include text files which will become part and parcel of your program before it is compiled. So the preprocessor works to include those files. So here is a possible implementation where I have this class stack. Notice that I am defining char s size, but the size itself is not defined here. You will recall that we had used hash defined size as 10000. We had defined these two. We continue to use that in our main program itself. So please note that this stack dot h file cannot be compiled unless size has been defined somewhere before this file is included. As usual, I have the top of stack integer which points to the top of any stack where a character can be inserted and then I have these three public functions. So the rest of the implementation is exactly identical to what we had seen except that the entire class definition is now removed from our program and it is kept in a separate file. So here I have the init stack. We just initializes the top of stack. Here I have push character c. It checks whether top is equal to size in which case there is no position to place the character. Please note that tops always denotes the next position empty in the implementation of stack as an array. So the next empty position is where you have to push the next character. However, if that next position itself is equal to size and that total element boundaries of the array is 0 and size minus 1, I can't implement it and therefore I say stack is full. Otherwise I assign c to the top of stack and increment it off. Notice that this array, etcetera, etcetera is part of this and is part of the private data members of the stack. So look at this, char s size that is the array which is going to implement the stack. The pop function just pops a character. So it has a return value called character. It will first reduce tops by 1 because tops points to the position which is an empty position and therefore the first character of the stack is actually 1 less than that. So I reduce that and return tops. When I return the character, when I have popped it off, the current value of tops becomes the next available position because that position has been logically made empty because that character has been popped out. Obviously if I have no character to pop, if the pointer points to 0, then I announce stack is empty. Notice that these implementations of push and pop do not permit me to examine such extreme conditions in my program from where I will invoke these functions. I will need some mechanism because I may not want in a more complex program where I use these stocks, I may not want error messages to be given by the class member functions themselves. I would rather have the member functions return some indication to me so that I can use it judiciously to decide what error message I want to give. That is the reason why you will find many of the member functions of such classes have a return value. In this case, char is the return value. Notice that I am returning an arbitrary character star so that if I locate a star then I can know that there is something wrong with the stack that the stack was programmed. However, it is quite possible that there could be a star as a legitimate character and therefore I have a problem. So we will see exactly how do we handle such things later when we discuss the editor class. The editor class itself is defined. It could be defined as another file called editor.h. In the example program that I am showing here, it is included as part of the main program itself but you could separate it out. This is the kind of documentation that is expected to be written incidentally. I have been repeatedly emphasizing it. I have seen some of your submissions of stage one. The programs are written and there is some in-line documentation but there is no comprehensive documentation at the beginning of every program code which says what that program intends to do, who wrote that program, for what purpose it was written etc. These may appear to be trivial things from a technical point of view but as I have said again and again these are as important and if not more important than the actual C++ code that you write. Without that the program is not very meaningful. Please note the acknowledgments. These are the kind of acknowledgments that are to be written. Particularly as you grow more familiar with programming and write larger programs, you will be using code which others have written. In fact, the best programmers are those who do very little coding themselves. They should be able to use the code that has been written by others effectively. And whenever you, because reinventing the field is far more costlier option in time and efforts, not required. However, wherever you use anybody's code, you must acknowledge that code and use it only if that code is in open source. Otherwise, if it is intellectually protected property such as non-open source code and if you lay your hands on it, you must seek the permission of the original author who holds the intellectual property to include that code in your program. There are variety of software licenses that exist in the world and sometimes should become familiar with the plethora of licenses even in the open source. It is important to reflect on the intellectual property being a valuable asset and its use without permission is akin to a criminal theft. There is no other word for that. In fact, Indian laws actually are quite strict on the intellectual property violation. This is the inline documentation of the purpose or objective of this program. So I am saying class underscore set. This is a set of programs to illustrate the definition and use of C++ classes. This set has three versions and this file contains the second. The version which we saw last time is actually version one. So I have called it set one underscore editor dot cpp. I will put that up on the model so you can see that version, this version and the third version which I will briefly talk about, but I will leave it to you to attempt its implementation and then I will put it up on the model. So notice how we build on the documentation that we had seen earlier. We say we continue to use the two stack model for editing. The stack class and functions are used in this set. Additionally, the editor is implemented as another class and the member functions of this editor class carry out certain predefined editor commands explained below. You remember I had said that I should be able to get commands from the keyboard such as insert this word, move cursor to 20 position or delete five characters, et cetera, et cetera. It is not adequate that you and I understand in our minds what those commands are. It is important to articulate the command format so that when we write the program, we would write correctly. Many times you tend to first write the program and then write commands of this kind. This is all right when you are under an exam tension or a submission tension, but this is perfectly incorrect if you are doing a project. So the way the project should progress is anybody who is writing any program should first write at least 20 lines of command for that program, at least before you write the first line of code, before you write int main, before you write include, before you write anything. That should be the method that you should follow. So here I have decided on the commands. This is my decision. Like I am doing a project like you are. Somebody has asked me to define editor classes or how to do editing. So I have assumed that I will, M followed by a number will mean move cursor to the specified position. I followed by a word will mean insert a word. Now I am simplifying the issue by saying that the word to be added should not contain a blank. Why? I am going to read the command input from the keyboard and in keyboard I can read a text string provided there is no space. Remember if I declared an array name of characters and if I read name as C in and if name had two parts first and second name, I could not read the two parts because after the first blank the C in operation will terminate. We shall see later in further versions of editor how do we handle such larger string to be inserted not just a single word. But for simplicity this particular version implements I followed by add word as insert the word to the left of cursor. D followed by a number will delete characters to the left of cursor and finally when I finish everything I will say Q which means quit editing is over and edited text is to be written to a file. The commands and their parameters are read from the keyboard. The main program illustrates the editing by using a text file and some sample edit commands. So this is the documentation. Now this is the set to partial implementation. This is not the complete implementation. I am now describing the classes for editor which are required. What am I required to do in my editing? I need to move cursor here and there. I need to insert a word at the cursor. I need to delete some characters and I need to quit. So I will have to obviously have editor functions which will implement these things. Here is the editor class that we are trying to define. I am defining size as 10,000, text size as 9,990. Why 9,999? Because when I read a text to be edited it is not necessary that there should be a backslash 0 at the end of that text. I might want to treat the entire text as a logical character string in which case I must have a place to insert backslash 0 myself and therefore I am keeping that one position extra there. It is not necessary but this is just a precaution that you can take. As we shall see as long as the number of characters are much less than 10,000 it is okay. Incidentally there is no reason to define this as 10,000. It could be 100,000. It could be 1 million. In fact the maximum text that you can edit at one time would be limited in this implementation by the main memory that can be allocated to a single character array. And if you can define two character arrays like that, one to hold the input text and another to hold the output text after editing, and a million character array is no big deal these days on most of the machines. And a million character is a lot of text. You can in fact read the entire file of text to be edited, push it into the character string buffer and then apply the editor commands to this. Notice the way editor class itself is defined. So these are some hash defines include IO stream, include C string. The editor class is not being defined as a separate file. It is being defined as part of my main program. Just like last time we defined the stack class as part of our main program but included the class definition at the beginning of main program after the include statement. We are going to do the same thing with the editor class. This will be followed by editor class definition, the class member function definitions and then the main problem. However the class stack has been implemented through a separate file. Observe that I have hash includes stack.h. So this will preprocessor of the C++ compiler will first read this file. Notice the difference. These are in less than, better than sign whereas this one is in double quotes. This typically means that this file is to be found in the current working directory where you are. So if I keep that in the current working directory that file will automatically be included by the preprocessor. We now proceed to define the editor class and its member functions. You notice that whatever code we wrote for the main program last time, essentially you are factoring out some of that code from the main program and putting it into implementation of some of the member functions of the editor class. To begin with the private data for the editor class would be two stacks, the left stack and right stack. Since we have defined the class stack we can say stack, stack, r stack. This defines the two stacks. Notice also that the moment I put stack, stack, r stack under the class editor and by implication this is private data member because there is no public word here. It means that in my main program I have no access to stacks. Last time we saw in our main program we had access to stack but we could not access the array which was implementing the stack. The array was hidden inside the stack class and I could only say pop or push. I am going one step further in the abstraction and hiding unnecessary details from the main program. I am saying that the main program itself will have nothing to do with these stacks because these are private members of the editor class. So consequently in my main program I will deal only with the text, commands and if I want to invoke anything with these stacks I will have to do that only through the editor member functions as we shall see them evolving. I additionally have a text of text size, size and a word which is to be added if you recall we had said insert a word. So we expect the word not to be a very large word. We assign ten character positions for the word. I have size and I have cursor. So notice even the cursor which was the mainstay of my editing conceptualization is now hidden inside the class editor. In my main program I have no cursor. So the physical variable which denotes the cursor now becomes part of the editor class. I will naturally have some other value denoting the cursor position in my mind which I will have to pass to a member function which will now handle the cursor because member functions have access to all the private data. So this is how I define the private data and in public I define all the interface functions. So for example there is an init function which I have defined which takes the text array from me in which I have the text to be edited. It takes its size. Notice that this time the array is passed as a pointer which is perfectly fine we shall see how to handle that. Then I have int moveCursor followed by int pass. So whatever position I give the editor member function is supposed to move the cursor to that point. What does moving the cursor mean? Well move the characters by popping them off the one stack and pushing them onto another stack. And since stacks are private members the editor class member function can do that well. But I can't do that in my main program. If I want to move the cursor I will have to depend upon moveCursor function. And actually this dependence is good because I am completely removed from the details of the implementation of this function. Similarly I have text insert so I have a character star add word and int length of that add word. And finally I have int text delete int num. So this is a number which I give so many characters will be deleted. I have added as a good measure a function called int text display. Hopefully particularly when I am debugging I would like to display the text. As we shall see later this function is not very useful here because it will have to display by calling the stack. And in order to display anything you can only display contents of a stack by popping the characters out. The moment you pop the characters out the cursor effectively loses its significance. So if you want to really implement it as a member function of the editor class to display a text. What will you display? You may display the following. You may say cursor position is this. Left of cursor these are the characters right of cursor these are the characters. Now how will you display the characters to the left of cursor and right of cursor? Only by invoking a stack and by pop comma. But if you pop characters then no further editing is possible. In fact you will lose the characters which are popped unless you store them. So you may have to pop and you may have to push them back. That is why this display is not a very meaningful function here. I have just added that to show that initially when I think of member functions the member function names and the functionality will not fall from the sky. Notice that each of these functions move cursor, text insert, text delete emanate from my decision to have those commands for editing. I for insert, M for move, D for delete. Additionally I know I will have to initialize something with the text therefore I have an init command. There are actually two member functions. One is called the creator and the destructor. The other is called the destructor. This creator and destructor functions usually do the initialization and destruction of the objects. Particularly when the objects are dynamically created we shall discuss those aspects at a later time. Now the member functions. So int editor colon colon init again remember the way in which the member functions are to be written. You have to write the type of the value that is written by the function. You have to write the class name followed by two colons indicating that this function init is a member of the class editor because init could be the name of any function either in your own program or a part of some other class. So you always have to distinguish by that. And then you have this care start text int size. What am I supposed to do here? I am supposed to initialize the editor with given text. So I say int i care start p. I check whether the size is greater than text size. If that is I can't edit that text. So I simply give a fact that text is larger than my capacity and I return one. Notice I could have written this function as void editor colon colon init as we had implemented the stack functions with void type. Here I am deliberately including int type as the return value. Ordinarily the initialization is not supposed to return anything. It's supposed to take the text and push it in the stacks. But in case it can't push anything in the stack, how will it let me know that the editor is unable to edit anything.  If everything goes well I will return zero, otherwise I will return one. Exactly the same convention that we have been following in our main program. I could then whenever in my main program I invoke say whatever editor class object I create say myedit. If I say myedit.init, I could invoke it in standalone key way in which case it will just do its job. Or I could say some return equal to myedit.init and examine the return value. If the return value is zero, everything is fine. If the return value is not zero, I can give the error messages instead of giving this or in addition to giving these messages. This is the implementation that if that is not so, then whatever is the pointer I got from the main program, I will assign it to my local pointer p and for i equal to zero to size minus one, I will keep putting the value pointed to by p into ith element of text. Notice the use of pointers. Star p plus plus means first use the star p which is the contents of the p which will be the 0th element initially of the given array. I will push it into the 0th element here. Then I will take the next element because p plus plus will mean point to the next element and so on. When I can complete this loop, my text array would have been initialized. All that I have done is I have copied laboriously the text which was given to me by the local text array. Why did I do that? The correct answer is it is not necessary to do that but it so happens that I had written this particular code earlier if you recall. So I am retaining that code. This is slightly inefficient because generally when arrays are passed as parameters, I should use the original array itself and not make a copy but that's okay. This program is still work correct. Now I initialize the two stacks, l-stack.init and r-stack.init. Notice that here l-stack is the name of the object of the type stack class and therefore the function pop, push, init, etc. have to be qualified by the particular object name. So l-stack init will initialize l-stack, r-stack init will initialize r-stack and after initializing these two since I assume that the initial text is such that the cursor is at the beginning of that text. Therefore I have to push all the characters onto the right stack and that is what I am doing here. For i equal to size minus 1 to i greater than equal to 0 I push r-stack.push text i. So if I have character a, b, c, d I want to push d at the bottom then c then b then a and that is why I push it in the reverse direction. So I take the last character of text and push it first then I take the last but one character of text i minus minus, push it next and so on till all elements are pushed. Notice that this could very well be achieved instead of saying text i here I could have said star p plus plus it would have had the same effect. I have initialized cursor to 0 and return 0 so this will initialize my editor that means the text which has been given to me for editing has been pushed into the right stack properly cursor has been said. Notice again cursor, r-stack, r-stack, etc are visible only to the member functions of the editor class they are not visible outside. Here is a move cursor command exactly the same code that we had used in our main program earlier I have the position which has been given to me I collect it in a local variable newCursor I check whether the newCursor is less than 0 or newCursor is greater than size that means somebody is asking me to go beyond the file boundaries or text boundaries then I say cannot move cursor beyond this please give another cursor position in n and I return 1 here and you will notice this also is defined as int so that I can examine the return value and now the standard thing the newCursor could be greater than the originalCursor or it could be smaller than the originalCursor if the newCursor is greater than the originalCursor then I have to shift characters to left stack from right stack because the cursor is moving this way if it is smaller the cursor is moving that way so characters have to pop out of the left stack and go into the right stack accordingly I will implement this I will again use s-stack.push, r-stack.pop or r-stack.push, s-stack.pop extremely simple code really which will achieve whatever we want and we must not forget that after moving the cursor the cursor variable which is part of the editor class private data element must be reset properly otherwise if the cursor is at the old position I will have a problem so I am setting cursor is equal to newCursor there is a int editor text insert comma this will be used to insert my text again I have a add word and length again I am doing the same thing I define char star p I assign p to add word I move the contents of add word into word all this is not necessary the only reason this is happening is when I perhaps wrote the original code I probably used the word word now I have defined add word as a parameter the moment I do that I will have to either transfer it or change this code so this again I will say it is unnecessary but this is the kind of code that might get written first time when we write the functions because the functions of a member class will not fall from a sky you would usually implement the whole thing as a main program as a trial and you will extract code from your main program and push it into the function code so this is likely to happen the first time but when you clean up the mess you can actually write much optimal code here I am transferring the contents of add word here I am not sure that the add word will have a backslash 0 at the end I cannot assume that somebody has said insert these six characters the six characters may not be followed by a seventh backslash 0 so I will put one myself and that is the reason why I will define the word as 10 and I must specify in my condition that the given characters if it is not a string must not contain more than nine characters so that I have this position in any case I calculate the length of that word I define the new cursor to be equal to cursor plus length because observe that this word is going to get inserted into the left cursor so the new cursor will have to be defined appropriately and then I simply check if new cursor is greater than size I say I cannot accommodate word size so suppose the left tag is almost full to the brim the cursor is already on the other side there is a position for place for two characters it is not full yet so no report has been given to me by any mishap but if somebody now I say insert five characters at these positions I cannot that is why the new cursor is computed before this so I know where the new cursor is if that is greater than the size I will say sorry space only for so many size minus cursor characters and I will return one here otherwise I will push the characters from word to the left stack again for I equal to zero to length minus one I will say s tag dot push word I so I have character gets pushed remember on the left stack the words are the characters are pushed in the order in which they appear in the text first character first then next then next on the right stack on the other hand they get pushed in the reverse order so that together all of them make a sense as a continuous string notice that I must now push the value of new cursor to cursor because it is the cursor which is the determining variable for the position and of course I put the size remember the size of the text originally had some value thousand characters two thousand four hundred fifty characters whatever every time I insert or delete not only the cursor position will change but the size will also change and I must appropriately accommodate that only when I move the cursor there is no insertional deletion of characters then only the cursor value will change to new cursor whatever it is but the size of the text will remain whatever it was earlier so after every operation of insertion and deletion I must modify the size item here is a text delete this is very simple I have the numbers to be deleted I now set length equal to number again a stupid part of code because I could have used num itself directly I am assuming that I have written this code earlier in terms of length rather than changing my code I am simply saying length equal to num I say this is stupid because it results in efficient code but first time when you write it this kind of thing is perfectly all right if you have written a code, written that simply reassign values with parameters to the local thing just remember if you have to send back something then you have to worry about it but otherwise this is all and what do I do now? I check please note I am deleting characters so that means whatever are the characters on my left stack some of them will vanish now if I am supposed to delete 10 characters and if there are only 5 characters left in the stack I have 2 options I will say you ask me to delete 10 I have only 5, I have deleted all 5 but better would be to go back and tell that person that look you are probably under the wrong impression you may think that cursor is somewhere else and you are deleting 10 characters but that is not so there are no more 10 characters left in the so this is the approach that I have taken in this implementation says cannot delete up to given position and without changing anything I end again return 1 which can be used by the return value if I so want it having checked for the conditionalities I now proceed to delete actually and the deletion is very simple because on the left hand side I know how many characters are to be deleted in the left stack length number of character so for I equal to 0 to I less than length which will execute this iteration length time I simply pop from L stack obviously the pop function will return a character so I will collect it into CH which I have defined as a character but it is not important because it is getting deleted so I can simply forget it so I pop, pop, pop so many times and that's it but at the end after popping I know that my size has reduced I know my cursor has moved so I will set cursor to new cursor and I will set size to size minus length size minus length always keep track of cursor and size I have not implemented the display function but you can write it if you want to and you can examine how difficult it is because displaying contents of a editor it is not the original text array that you can display because that will still continue to contain whatever text you had we have not changed it what we are changing essentially are the contents of the two stacks so displayed edit, text being edited is not a easy command to implement in an editor class how will you implement it? you can't say that go to that stack and show me the seven characters which are there what you will have to do is pop characters from a stack and see out them but if you pop they are gone so you will have to pop them into an array display them and push them back in the same sequence back into there too much of Godagiri it's not a good way to implement it you might do better to have a display stack command because when you operate within the realm of the class stack remember you have access to the array itself which is implementing that stack so without pushing or popping you can directly display from that array whatever contents you want to display of course that is not a standard function for a stack implementation and therefore that has not been implemented here but in case you want to display why would you like to display that? you would like to display that only during the testing phase once you have tested that your editor works perfectly there is no need there is no need to display anything while you are editing except what string is being inserted what characters are being deleted if you want to display which characters are deleted you could add here ch equal to l stack dot pop see out ch it will display that correct or better still c out l stack dot pop so it will simultaneously pop and push it on to c out pop and push it on to c out you can choose what to do I would recommend doing this and followed by c out because if you don't want an output to be cluttering your interaction with the editor through commands you may simply blank out that c out position if the pop itself happens in c out then you remove c out pop also goes so that is one of the ways in which you can implement there are multiple ways in which you can handle now we write the main program what have we achieved so far? first we saw removal of all implementation code as well as independent variables required for implementation of stack in a class called stack log so that means we are no more burdened with the internal implementation of stack that would be an object which itself I was using in my main program last time now I am going one level further in hiding unnecessary details by defining editor class I will define some objects of the editor class here it is editor my edit my edit now is an object which comes into existence when I define my edit editor my edit what this means is that my edit now will have the complete internal information that is private to the editor class and I can interact with my edit using the interface function that I have so defined but all the definition of interface functions how to move cursor, how to insert, how to delete again becomes local and private to this object my edit my main program will therefore be that much cleaner notice that such implementation permits the stack class to be used by anybody for something which is a non-editing thing for a different thing somebody needs a character stack one can use it if somebody needs an editor not to implement these command line editing functions but maybe something else could use my editor class this is the kind of generalization that you can perform and this is the kind of reuse an object oriented programming permits you to do let us very quickly look at the main program I define the editor object my edit I define two arrays text and out text this 5000 size is a remnant of my last program notice that this is not necessary to have 5000 as the size what is the maximum size I can have capital S I Z E or capital text size that I have defined earlier it is better to define that using a hash define parameter said once I change that everything changing otherwise you may even make your stack worth 1 million characters you may make your editor class private element that text also 1 million but in the main program you can read and handle only 5000 characters it doesn't make sense now this does not happen when you are writing a single monolithic program because you are aware of all the different data structures and you will define all the necessary arrays with the appropriate size but when you isolated implementation when stack is implemented in stack.h tomorrow editor class itself which is now part of this main program gets implemented as editor.h then I won't know what those implementations are but it may be better therefore to use certain standard macros which are defined which gets replaced at the compile I have additionally an old cursor, new cursor text length, out text length and an integer variable I for my indexing all that I have tried to do in this particular main program this particular main program does not handle the commands that I listed at the beginning that will come in the proper version 2 or the set 2 of this set of program this is you can say set 2 trial what am I doing in this trial I am trying to do exactly what I did in my first main program namely take some text take some arbitrary word and see whether you can insert it at the designated place and see whether you can delete some characters basically I am testing each of the interface functions by using exactly what I did this kind of testing during the development process is an extremely useful thing because now I will know if this program works correctly that means the implemented member functions of the class editor are working correctly and then I can write later on replacing the part of this main program by a program which will take edit commands from me on the terminal and execute them appropriately so here is a sample text for editing I am just saying string copy a b c d a up to z I have calculated the text length I output the text to be edited so and so and its length is so and so and I put an ad word which I want to insert at some position as opening curly bracket 1 2 3 4 closing curly bracket notice that when I use either a string copy or I assign during the initialization the backslash 0 is automatically inserted by c++ at the end of this so I am equipped with a sample text to be edited I am equipped with a word which I want to insert and conceptually I know I am doing exactly the same thing that I did while developing my previous program so I am very clear in mind what code I need to written so what I need to do if you recall what we were doing there is we were initializing the editor arrays which means we are putting them in the right stack and so on but that job is now done by the init function so I have to call the init function then we are moving cursor to some position 10 then we are inserting this word then we are moving cursor somewhere else and then we were deleting some characters from that position observe how easy that implementation now becomes so those particular actions that we were taking earlier you will remember that for each of these actions we had tons of code all of that code has now become part of the editor class object and the editor class object that I have instantiated is called myedit so whenever I say myedit.init this object will be initialized with the text and text length that is my original text in this particular case the text is an arbitrary string a to z and the length is 26 but in actual practice this text could contain thousands of characters as I said next I want to move cursor to 10th position I simply say myedit.moveCursor 10 that's it it will move to 10th position next I want to insert the additional word I will say myedit.textInsert add word, string length add word notice that in this case I had explicitly calculated text length by invoking string length function elsewhere but it is not required I am going to pass this parameter as a read only parameter anyway so I can calculate that as part of the parameter definition itself next I move cursor to 0th position then I move cursor to 3rd position I delete text I delete 3 characters at that position and again I move cursor to 0 why 0? because when I move it to 0 the idea was that if the display function which I had in mind would assume that the cursor is at 0 and I will display everything from the right stack so while displaying instead of remembering what I have popped I will keep pushing it onto the left stack and display every character and at the end I will again pop from left and push it onto right however I have not implemented that function because by writing the program I realize that it's hell of a lot of work please remember if I am editing 1 million characters just to display characters I will have to push these 1 million characters out of one stack onto this and push them back but internally I know the stacks are implemented as an array so instead of the display text being a function as the editor class or I could have a display text function in the editor class but if I could additionally write a display stack function in my stack dot edge and from editor class I invoke that function then that function need not do any push or pop because that function is a part of the stack class will have access to the internal array which implements that stack but that is a matter of choice the question is in front of you how do you read a complete file how do you read data from file you first of all open a file for reading it has some name and let's say you have opened that file for reading with the name as this will be the definition so you can actually open the file how will you read we have had two ways of reading we said if it's a text file we can read it character by character line by line or string by string here we want to read all characters so we can read character by character what we will have to do we will have to set up an iteration which will start with whatever 0 it will read one character push it into the array text here you want to read that and go to read the next character at some point the file read operation will return no character to be read end of file so we have already seen how to test for end of file we will say function end of file so if f e o f is not in bracket f p is not true then we keep reading otherwise we stop reading remembering that we are planning to do editing for complete text that exists inside the file I know that I will always have to read the entire file can I not read the entire file in one shot because there is a direct access mechanism available to me even though if I open this file for read and even though it is not a binary file remember I can directly access any position in the file and read as many bytes as you specify to recall if this is your file and let's say this was the last position how is the last position named in file system a position pointer called set end how is the first position named how is any position elsewhere named current position are these pointers to these positions you have forgotten these are not pointers to these positions in fact these are flags used by the file system the set begin as a pointer value as a value 0 this has a value 1 and this has a value 2 these don't indicate the position the position is indicated by some kind of a long int say pos all that these flags indicate is I could stipulate the position with respect with relative to beginning relative to the current position related to it originally I have no clue how many bytes does the file have if I knew that let's say file has file size bytes suppose I knew the value of file size let's say 1 million or 2,20,000 or something then I know how to read all the bytes how would I do that I would do that by saying fread you remember the fread command what is the first parameter of fread fread does not have file pointer as the first sorry the string in which you want to store the bytes read from the file so let us call this text because we want to read everything in the text tab then we want to give the size of the block that is to be read and number of blocks are to be read I can read 4 byte blocks 20 of them I can read one block of the entire size or I can read one byte block number of the size number of times so if I say for example read fsize bytes block just one unit and do that from set what is the begin is just begin is it so seek set seeker and seekend and therefore I should say in fact if I don't say anything it will take it from the beginning I presume but I'll just say seek set the issue is I can read the entire file but how do I find the file size any idea how will I find the file size ah he is suggesting a method which we just thought about for displaying text in an editor how do you display a text in the editor you pop from the start and keep doing it so what he is saying is first you read every character keep counting whenever the file ends what are the total number of characters you have read that is now the size and now you again read the entire block I have already read one if in order to calculate the size of a file if I have to read characters and count them then I have read them anyway which means I would have set up an iteration etc etc so there are two additional functions which you people don't seem to have read so I'll repeat again if you recall we had said that there is a library called C S T D I O the C S T D I O has all the file functions these are the classical file functions the additional file functions which are part of the C object library which is the standard template library of C++ I had said that we are using some of these file functions in C S T D I O and there are many others which you should read for the sake of usage and at least for the sake of curiosity neither seem to have happened so let me tell you two functions one is called F T L F P this F T L F P tells you where the current pointer is of course your current pointer when you begin the file is at the beginning so that is not very much helpful because it will return a position 0 if the current pointer is on the seventh byte it will return 7 if it is 25th byte it will return 25 but we know how to set the pointer at the end how do we do that F C we use this F C before reading anything remember we saw that if we want to read let's say 24 byte from 100th position we have to set the pointer to 100th position what we are doing we are giving the value 100 relative to beginning as we know we can give a displacement relative to either beginning or the current position or at the end suppose I give a position relative to end and that position displacement I give as 0 will my pointer not be pointing to the last element so if I say F C what is the format for F C file pointer number of bytes displacement relative to whatever point I will say that is 0 and the F C function will set an internal position pointer by this command at the end because I am saying 0 with respect to end it can position is beyond them however it does not return a value or does it it doesn't return a value but F tell F P returns the value of the current position so if now I said so this is the use of this F tell function that I don't I don't read please understand the difference between reading every character and counting versus simply internally positioning the file how does operating system do that because operating system actually knows the size of the file whenever you create a file edit a file insert characters whatever whatever and whenever you save a file at that time the operating system retains the name of the file the pass pointers whether it is directory what type etcetera and the size of file invites this information is known to the operating so when I say that is how it can move things relative to the end otherwise it has to know the end itself operating system knows it and this is my way of doing it I will tell the operating system please seek to the end of the file and then say tell me where you are it will tell me which I capture in F size now you will agree that I can do an F read here is that okay why is not okay F read always works from the current file position the current file position is at the end of the file it will try to read 1 million characters from that point it won't find any so I have to bring it back here it can be achieved by again doing an F seek F P 0 with respect to write at the beginning all alternately there is another command it says rewind F P you are familiar with rewinding a tape musical tape is rewind so you press the rewind button it will come at the beginning of course the rewind operation is much faster because it has to set the point of so notice how neatly we can read the entire file without any iteration without anything without doing any work please remember this F read is much faster than iteratively reading one character why why is this much faster than iteratively reading one character after all the F read will have to put everything into the text whatever we are saying say one byte F size time or F size bytes one time whatever it is why is this faster than using an iteration two reasons every F read command actually makes the operating system go and physically read from the disk please remember the disk is perpetually rotating disk is not waiting for you your file and the various bytes are located at different places based on how the file has been organized by the operating system if you read one character and assume that all bytes have been logically written sequentially on the disk for efficiency say if you read one character the operating system will read one character and it will give it to you in the iteration you read next character the operating system will again go to the disk by this time the disk has moved so it will have to wait for half a rotation that would be very stupid to read one million characters like that so operating system does a smarter thing whenever you see read one character it will actually read one block and you keep it inside its buffer next time when you say read I say I have read that block so it will give you the second character it will give you the third character block is typically 512 bytes by default it could be 1 kilobyte, 2 kilobyte, 4 kilobyte but if you are reading one million characters several blocks will have to be read independent it is possible that the blocks were written sequentially on the disk so if you read all of them in one shot in one single rotation of the disk you could read the entire file whereas individual reading will take much longer in particular whenever you are doing read write operations on disk you might want to be slightly more careful about efficiency then you have been earlier where you could easily handle moving things from this stack to that stack or this array to that array etc ok now how do you handle the editing commands so I have read the text I have initialized the editor now suppose I say move 10 so the editing command can be handled by setting up an iteration an infinite iteration practically so do why what I will do see in character edit command I will define edit command as a car that edit command could be m i d or q I could use a switch statement switch based on that edit command character case q quit case i read the word again by cn and insert case m invoke move cursor case d delete and if this sequence I operate I can implement it so my entire main program will consist of reading from a file initializing my edit object and then writing a loop continuously keep getting editing commands from me and executing don't you agree that the program will become much neater and conceptually cleaner because your program for editing is actually doing editing it is a command editor you can call it a command editor program it uses two classes the main class is editor class which implements move cursor etc etc which in turn uses the class for stack this is the right way of evolving your programs later on we shall see how we could put these files not only these information about class implementation not only in different text files but we could even compile these and kept them separate indeed that is what we mean when we say we use cstdlib or cstdio or cstring or whatever whatever any library where we use the functions the prototype functions are defined are made available to us from those libraries while compiling the actual code which is translated already pre-compiled is linked with your program during the link time that is how the system works