 Hello and welcome, this is video three in a series tour, check out the previous ones, especially this one we're going to build on to the exact script we were running last time, last time we wrote a program called name, it asks for the user name, I can type in my name and it says hello whoever and then it's supposed to continue the message there, but we're using fgets which is capturing, when I hit enter it's capturing that new line character and adding it into the variable name. We want to get rid of that. And there's a number of ways to do that, what we're going to do is it's going to, we're going to basically look at the length of our string that we're capturing, our name variable, we're going to look at that and basically cut off the last character of it which would be the new line character. Depending on what variable you're working with, you may want to do it different way, but since we know that we're using fgets and the user is going to hit enter, it will cut that off, although I guess if you set it to 20 characters like we have it set and you type out 21 characters or anything above 20 it's going to cut off that last character. So keep that in mind, again there's lots of different ways to doing this. Let's go ahead, I'm using vim as my text editor, you can use whatever text editor you want. So here we are, we're including our standard input output header here, we've got our main function, we're setting our variable name, we're printing out to the screen asking for the user name, we're getting that user input and then we're printing that, but again with the problem of the new line character, so before we print it out we want to remove that, but to do that we're going to use a header, so we're going to pound include what's called string.h, string header, and that lets you do certain things with strings, and in here what we're going to do is we'll leave this print so we can see what's going on here, but we will copy that, whoops, copy that, and what I'm going to do here is now we're going to print out once with that line break, that new line break that it's capturing in fgets, but then we're also going to use this size underscore t, and we're going to create a variable called length, and we're going to say that's equal to string length of name, and so we're using here this function comes from this header, that's why we've had to include that, so we're basically saying get the length of this string, and we're putting into a variable called length, short for length, okay, hope you're with me so far, now we're going to do an if then statement, and actually let's not do that, let's see if we can skip that, I'm going to say name because technically our name variable is an array, which we haven't really talked about, but we're going to get more into, we're going to say minus minus the length equals backslash zero semicolon, so what we're doing here is we're replacing our name variable with name variable with the same thing without that last character, so do that, we're going to say compile gcc.name-o for output name, no errors, we're going to say name, and now I'm going to say Chris, so it should do, it should print the line once with that line break, and then should remove that line break and print that message again, there we go, so you can see that we have here hello Chris, and then that line break from what we're capturing from when the user hits enter, it's saying comma how are you, then we're removing that new line character, and we're saying hello Chris how are you, originally I was going to check the length of the variable name, and if it was empty, basically skip over the length, and we don't need to do that, let's see if it causes an error, no it doesn't cause an error if I just hit enter, it just removes that and now the variable is empty, so again let's look at that, again we're doing fgets, which is saying get from the standard input, put it into a variable called name that is the size of name, which is a maximum of 20 characters, then we're printing out the message with that, and then we're saying here get the length, we're creating a variable called length using a string function, string length function from the string header, and we're saying look at the name, how long is name, that's what we're putting in length here, and then we're saying minus minus length, so basically that's saying okay, look at the length of it, if it's 10 characters, we're going to subtract one for it's going to be 9, so it's going to be cutting off that last one, it's basically what we're doing, we're saying take that last character and just bleed it, and then we're going to print out here that same message, but this time we don't have that extra line break, so I hope that made sense, again gitlab.com forward slash middle x 1000, forward slash my bin, capital M, capital B, there you can look through the project, there's a C folder that brings you into a folder, so this is the C folder here, this is the tutorial folder, and then the code that we're looking at here, at least very similar code, is written through here, you can look through our examples here. I do thank you for watching, and this is the one we just looked at here with the if statement, I almost did, thank you for watching, and as always I hope that you have a great day.