Hi guys.
Welcome back.
In this tutorial we're going to learn about strings in C programming language.
OK.
What is this string.
OK string is one dimensional array of character that is capable of holding a string value.
OK.
And please note of when compiler and code does this sequence of characters enclosed in the double quotation
marks it upends a null character at the end.
Okay.
For example I am declaring and initializing a value called string.
Okay.
In this character Adi.
Okay so if this year 1 2 3 4 4 There are 6 characters.
But I had defined with the Seven okay memory allocation for seven.
Okay.
So what happens is like by default when it sees the rotation on the sequence of characters by default
at the end C compiler will append and then character.
So whenever you are initializing the string value make sure you keep one more space one more room for
the for the null character.
Okay so if your string value is six then you should be seven if your string values eight then it should
be nine.
Okay so take note of it a by default the C compiler will append an Alcatraz at the end of the string
value.
Okay.
Hi guys.
Here in this territorial we learn how to declare an inch laser strings in C programming language.
Okay we can no strings in a number of these.
Okay this is one V here what we have done is this is that data type and this is a variable and there
is no definite space was allocated and the value of Dennis was like Dennis was insulated to this really.
Okay so this one we all for declining and insulating the string value the second way is weird we can
each oppose a frame using the value as Dennis as any other and now that string which have a six character.
So what I need to do use like what do we had to do use like we need to put one more space for the null
character which for example here is six.
One two three four five six.
Okay so 6 press 1 7.
So what needs to be allocated for the memory category.
Okay suppose you mentioned a six year right.
Like at me end up with undesired results during the competition.
Okay.
So make sure that whenever you're initializing a string value to a character Ari.
Make sure you keep one more space for the null character not by default the C will see compatible up
and character Bennett's show when it sees the double sequence of characters with W condition.
So.
So this should be always one more space for the character.
Okay so this is there are two ways of initializing get string value.
One is with space with the definite memory allocation.
Another one is with the indefinite memory allocation like maybe we can just do this as great bracket
and by default the C will allocate a memory for this particular string value which you are getting instead
to the C that one character variable.
Okay so here it is here.
There's one more v I's like you can declare and insulate the string value in this format also which
is also incorrectly.
So this is the third V O for the cladding and slashing here and there is no definite space for this
cat ready.
So the codebase is uniting unity and put all your characters which you want change to a character variable
and similar to this one you can put you can allocate a different space also.
So here as Denise I have just mentioned this seven here.
So here one two three four five six character values and one is for the character for C compiler.
OK so there are four ways to declaring Shlaes a string but I feel this is one of the better b and easiest
history.
So we will see further with the help of a program OK.
If you see here this is one of the basic program where we are declaring an initializing string value
to a string variable as a mentioned in the recession.
These are the four times which we have seen.
So one is with that defined got it ready.
And the other one is with undefined.
I'm not different any special here.
So with the double codes and these are the two types and also the code liberates as you can initialize
value where you can key all your string values or here and yet undefined space similarly you can use
it with defined space curly braces and 1 1 1 1 space you need to leave for the null character.
Okay so there are the food types of the cladding and insulating string value.
So if you execute this one doubtful within the same but as I thought earlier this is the best ways and
the simplest way not to declare initialize a string.
String value.
OK.
So let me compile this program and see what is output
see you see here
we have a printer.
This is the declared initialization and I'm printing this value here.
So did printer Dennis again I'm declared and insulated with different size of seven which means six
is for the character which means you're going to one for the null character a null character sort of
37.
So the output is saying this is what I'm going to see if C. diff is just printed here.
So now again I'm printing this value here which is also Dennis with undefined size actually on different
size but I already mentioned I already input the null control here.
So similarly with the different space here with the name put on my string value in the curly braces
OK.
If you see right there are four types of for declining initializing a string variable however.
But the value but the the output is same.
So you can use any one format in your program like giving you a window declared on insulator destroying
value.
OK.
So as I told earlier this is the best way so no further programs like we'll use either this or this
way of the cladding initializing a string variable.
OK so this is a sample program which shows how to declare change lies and print a string variable.
So thanks for watching this video.
We will see we'll discuss further in the upcoming session.
OK.
Thanks for now.
We'll catch up with the decision but.