 Hey everybody, it's Brian. This is our 16th C++ tutorial. Today, we're going to be covering strings. Now, C++ handles strings in two different ways. We're going to cover the C-style way, and let's actually put a comment out there. C-style. So, you understand what we're talking about here. A C-style string is an array of characters. We've covered arrays before. Let's just show you what we mean here. Care, and we'll say name. And we have to give it a length. We'll say 80. And let's initialize this. Let's initialize the same way. Initialize another array. But the trick with C-style strings is they always end in character 0, or ASCII 0. Now, why is that? That's a good question. A lot of people don't know. Basically, it ends in character 0 so that the compiler knows that's the end of the string. So, how do you work with the string? We say C out. Enter your name. And then you want to C in. Name. And C out. Hello. And let's just print the name. So, what we're doing here is we're declaring an array of characters. 80 of them. We're initializing it to 0. And we're going to say enter your name. And then we're going to read the input into the name variable. And then we're just going to print it back out. So, when we run our program, it says enter your name. Enter your name. It says hello, Brian. Or whatever your name is. And press enter to continue. So, as you can see, working with strings is pretty simple. It's just an array. Now, there's different ways you can do this. You could always initialize it. For example, I've got some code pre-written here just to save some time. You could initialize it this way. You know, the individual characters. But that gets a little bit cumbersome. You can always use the shortcut, which is where you just put it in quotes. And the compiler will automatically parse that into an array. And let's actually just show you how that works. Sure enough, it says hello, Brian. So, we've initialized that array to these characters. That's the C-style method. The C++ method, however, is a little different. We're going to include string. Remember, pound include is a pre-processor directive. Meaning we are going to include all the code that's here. Now, what is this string? This is a class. Of course, so is IOStream. We haven't covered classes yet. But what you should know about classes is they are a blueprint or an object. That's what C++ really brings to the table here. The advantage over C is that it's object-oriented. It doesn't force you into object-oriented programming, but it allows you to do it. So now that we have our string, which is part of the standard type library, we can simply do the C++ style, which is where you say string. We'll just call it myName equal. Looks like I fat-fingered that a little bit. And let's just print out myName. And as you can see, it does the same thing. Now, what's the difference here? Why do you want to use a class over an array? You already know what arrays are. They're convenient. They're easy to use. Why would you want to use a class? Well, I'm going to try to explain this in the sense that you don't really know what a class is. So let's back up a second. A class is a blueprint. It defines an object. For example, an array, you press name dot, nothing happens. Because it's a variable, whereas this variable is actually an instance of a class. Notice how when you type myName dot, you get all these items. What are these? Well, these are properties and methods inside that class. So that's what a class allows you to do. It allows you to define things. For example, you can make a class called house. And inside the house, you could have the color of the carpet, the color of the walls, the ceilings. You could have a function that opens and closes the windows and doors. That's the power of classes. And we're going to get into those in another tutorial. But I really just wanted to drive home how strings work. It's the basic building block of many other things you're going to learn. And in case you're wondering, yes. You can do the same thing with the C++ style that you did with the C style. So for example, we're going to just say enter your name and we're going to read in characters into the C++ string class and then print it back out. Let's run this. And we'll just say my daughter's name is Heather. It says hello, Heather. So that's strings in a nutshell. This is Brian. Thank you for watching. I hope you found this video educational and entertaining.