48 - STRING HANDLING FUNCTIONS - C PROGRAMMING

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hello so initiation let us have a look on strengthening functions so in the previous session we have seen what is the basic chain so string is a group of characters so in order to store a character in a variable we have to declare that variable as a character definitely but here the string is a group of characters that means the collection of characters so as we discussed in the previous session group of same data-type group of same data-type elements are called so a string can be implemented by using character X so that means if you want to same string into in in a variable we have to implement that string using means we have to declare one array with a character data type so that we can save a string into the particular and as we have discussed in the previous session and the end of the string is a slash 0 that is null character it is represented as / 0 / 0 so this is not alphabet war it is 0 numerical 0 so this is will be treated as an end of the string and also we have saying different input and output functions to read the string and to print the string so there are three input functions we have seen in the previous session that is using scarab quick everything using get care you can treat the input and you using get s you can read the input string and to display the output we can use the printf statement or we can use a cap function or we can use a put s function so whatever it may be the end of the string is denoted as slash 0 so in the reading the input string after reading all the characters so the last character will be using slash 0 that means the /g normal character will be offended at the end of the string in the input form and coming to the output function the compiler will simply print every character until it reaches slash do that means either using the printf statement we can print a entire string that means enter line of text or we're using the Buddhist function or a put care function we can print the line of text so when X comes to the input functions by using the scanner the compiler will treat the space as a null characters so we can give the input until the compiler reaches the space that means until the user acts the space bar space button so whenever the user types the space button automatically the compiler will treat it as an end of the string similarly coming to the get care and get s so both in the both functions the /n will be the end of the string that means the computer will read the input until the user press Enter button enter is nothing but slash the end the newline character so until the user enters the /n it will keep on taking the input Assisting that means and well enough text can be given as you can put where escaping to the scan of only a single words can be given as input so finally the last the last element of a character array is in mouth character so coming to this string handling functions there are mainly there are different texting handling functions in this session let us have a look on if you see handing functions one is the first end of foremost thing is string length second one string copy third one string concatenation fourth one string compare next string reverse low to upper case characters upper to lower discount September stop hello to uppercase and upper to lower case so mainly these these are the different string handling functions and we have a pretty different function for every operation so for all these operations we have a syntactic function that is three different functions so we need not write with any logic or any code in the program just by using the predefined function we can implement this string length Austin copy string concatenation string comparison or string reverse in the remainder so in this session let us have a look on all these predefined functions so coming to this first string length coming to this chain length the name itself indicates this function is used to the function predefined function is STR LVM string length so this function is used to get the length of the string that means how many characters are there in the string so this function will exclude the null character so if our function our string is having hello and the ash characters my character so the Steven function will give gives the ransom as one two three four five only five so it excludes this null character it doesn't count the null character it only comes all the characters and coming to the string copy the names indicate the here the function is strcpy so then every self indicates this is used to copy the content of one string into the underst and the third one is concatenation it is represented as st FCAT that means that if i function for concatenation is STR see it so this is just like appending the content of one string to the understa so at the end of the first string we will just write the data which is on the second string so thus we call it as éponine appending of strings that is concatenation and then string comparison so for this the representation is STR cmp companion so it compares whether the both strings the content of both strings are equal or unequal and coming to the string reverse it is STR Reeb the name itself indicates so string we must function easily used to reverse the string given string there was the content of human stream and we'll go to a perk is yes t an uppercase so if they are u P R so this function is used to convert the all the lowercase characters into uppercase characters and similarly yes dear yes whether you are so this function is used to convert all the uppercase letters to lower this characters so all these are the different string operations or string handling functions so for every operation we can use these predefined functions so as it is a predefined function so in order to implement these three different functions we how to include string.h so that we have to improve the vibrating fire or I have a file that is trained on it so unless you include this treatment page these predefined functions will not work so in order to implement all these functions we have to include the string dot H header file in our program so first of all let us see one by one thus in Texas at a simple example so coming to the string then stiyl the name itself indicates it will return in length that means the length means the number of characters in the given string so the number of characters is an integer datatype so this statement will always returns an integer datatype so we have to assign this string length function to one variable so that the length of the string will be assigned you choose that name particular variable so this will return the integer data by excluding the male character so so returns integer and excludes the my character in the stream so here the my character slash zero right so we have to assign this predefined function to a particular variable so thus index will be so some variable integer variable is equal to string above Steve so we have to consider on sting that was a character and so we have to pass that character as a as an argument to this function so it takes only one argument that is straining so this is string name so it will come on to all the characters in the string name excluding the money character and it will return to the variable so if you write a program for this see finding the string length that is yes t our LVL function so main function first declare a string that is character some let us take a name as a string name of 20 sub 20 characters and now let us take the input so that means I will use the data function Gettis of name so that it would read the every character until the user press / n that means end of enter button and now also declare one more variable int learned any yelman so length is equal to yes they are alien off right the street ending and then printed length is equal to percentage B so if we declare this name as C so let us take one vector initialization let us take this one so h-e-l-l-o and sliced you then this will return the handsome as one two three four five so it will return the answer that means that the length of the string is five so before using this we have to mean blue string dot H and also we are using here printf function so we have to use a string over each standard input so that is common and for implementing these streamlined function we have to use this string dot H 1005 so this is all about string length so now let us see the second thing that is still copy Stinkum so here we will copy the content of one string to the another string so the function is STR CP Y and it will take some arguments so the syntax for this string puppies yes T our CP by destination string comma so stick this relation stick and fosston so here we are supposed to declare those things and we have to initialize one stain and we have to copy the content of one stain to the second step so in the in such case we have to so here this string copy function will take two arguments as inputs so first one is destination string that means - which string we have to copy the content of our system so that we have to write the first and the next the source string that means which content should be moved to the or copied to the second string so first we have to write the destination string and the second is whether we have right to the source system so this statement implies the content of so sustain is compared to the content I mean copy to the destination string so for example let us look at the example right now the main function and then you have to declare two variables I had two strings and then we have to initially the only one string now I will recur captain yes tr1 of 20 is equal to hello and character STR - of 20 so I have two strings one is a sainted sub string so second one is an industry now I will write I have to copy the string the content of state 1 to state 2 so strcpy that is cheap copy write the destination so where we have to copy the string so I have to copy the stain from string 1 to state 2 so that its destination is straight so string to come back so from where we have to copy the data that is still one simply print the strength to tendon string poop is equal to percentage yes yes tr2 so this is the base best example a simple example to understand this working of stink of it so if you take two arguments one argument is at this station and arguments is a source now let us move on to the next thing that is string concatenation sentient attention so the pre different function is STR c8t STFC 8 here also so the CRC is concatenating the content of one strength to the content of another stream that is a pending so we have to add the content of second string at the end of the first step so here if the string 1 contains hello and the string 2 contains welcome so string concatenation will do the welcome will be added at the end of stigma so Stillman content will be having hello and welcome so appending depending the content of second strain at the end of the content of Foster straight so here also we have to take two arguments in the function so that is also distillation string and the social strain so here the destination string is so where we have to append in which string we have to affect the content and come to the source string is which content is to be appended to the other stream whose content is to be appended so this nation state and so string so the only thing is difference is the function name STR CID here also we can have s TM see it so here there is a difference because in the previous thing that means the string copy only one string is initialized on the stage is just declare but in this case the both the strings should be declared and initialized and then we have to cut catenate the one string at the end of the another step so here are my letters delicious two strings that is Sheridan here so fasting was initialized to hello and second sting was initialized it to welcome and now I have implemented the stick concatenated function the sources thing is string one so that content of string to should be offended at the end of the can at the end of the content of strength one and the force is string to that means which data should be appended so here thus the dead of string to is appended at the end of stigma so but if you read this thing one so if you print the string one the output will be hello and so we have concatenated the rectum and the end of n so that is the use of string concatenation function so here so in order to implement this string concatenation function we have to include the string dot h elephant and the next one comparison still convention so string comparison c NP the syntax is see here also the name of seven digits if we compare the contents of one string with the content of under string so for that purpose we have to give two strings as an inverse so that means we have to declare two strings and also we have to initialize two steps and then we have to perform the convention function so what it will it will result I think what it will return this function what God this function will return so this function will return an integer value so it will return integer value so this integer value can be 0 positive or negative so any value it may return any value it may be 0 or it may be positive or it may be negative so if it returns zero that implies the truth strings are equal two strings are equal if two strings are unequal that means if any one of the character mismatches with the two strings then it will return the difference of the difference of mismatched characters from postings so it will return the difference of so it will return that as key difference of mismatched characters are two strings so first of all it will compare each and every character from God first the first string to the second string and if it found the mismatch then it will convert the character in the ASCII values and the difference of those ASCII values will be written as an output so if the mismatched ASCII value of first mismatch character is greater than the ASCII value of first mismatch character of second string then it will return positive so ASCII value of mismatched character of first string is greater than ask a value of mismatched character of second string then it will return positive value and it here also sin it will also return ASCII difference you also have to the SD difference so if the ASCII value of the mismatched character of first string is less than the ASCII value of mismatched character of second string then it will return negative M so finally this string comparison function will return either 0 or positive or negative so if it returns a 0 that implies that two strings are equal if it returns is a positive or a negative that implies both strings are unequal and it will returns the ask a difference of mismatched characters of both the streams so positive and negative depends upon the ASCII values of mismatched characters so this is all about this string comparison function next stream give us stay the bus function so it will simply reverse the content of given stream so the predefined function is STR our rav4 shop so this string reverse function will take only one argument that is a statement so which content should be reversible that string should be passed as a parameter for this function so the syntax is yes t are rivers of stream name so automatically the content will be reversed and it will be stored in the same stream so we are stated example right the main function then here only one string we have that we have taken soap we have to declare and initialize only one string character string just a simple yes TR of from T is equal to take the same hello so and I am taking the direct initialization so in the programming we have to use the run tank initialization so hello and after the string reverse function STR our EP of st are now print the STR drink them Ramos is equal to percentage yes yes T so this program introduced that means implements the string reverse function so it reverse the content of string and it will be share with the same stream so the output of this function is oh la e H if you think the content in the so for this purpose we are using string reverse function and here also where in order to implement this string of a string reverse function we have to use the string dot H header file then the conduction of lowercase to uppercase North to upper case so for this purpose we are using yes TR u P are the function three different function is s TL u P R so let us take the feed X so here also it will take only one argument as a input and it will find all the lowercase letters and it will convert the all the lowercase characters into uppercase characters and all this will be saved at the same string STR u P R of streaming so the lowercase letters will be converted into uppercase and the same will be saved in the same string so if you write the program so we have to declare and initialize only one street so character STR of xx is equal to hello and then I will use this STR u P R of s DF then print the same string printf uppercase is equal to percent IDs yes t R so this function will convert all the lowercase characters into uppercase characters and it will be saved in the same string so the output of this program will be all the lowercase characters converted into a puppies characters so for this also we are just using the predefined function similarly uppercase characters to lowercase characters uppercase to know what this said yes dear yes WR lower so here also the same project LWR okay also we will take only one stick as input and here also all uppercase characters will become rated to lower case and it will be saved with the sense T so here let us take the initialization of uppercase characters and we will apply the predefined function STR and the value of STR and if you print the same string lower case is equal to percentage yes the output will be so if you convert all the lowercase characters into lowercase characters so this will be the output for this predefined function so here also in order to implement this two different functions we have to include string dot hitch chemical hope you understood these string handling functions and these are very few string hanging functions the Majestic operations or predefined functions so there are many string handling functions and for everything we have to if if the same having function it is a predefined function that definitely we have will uses check not H in the program so unless you include the strict of which header file to the program you cannot implement these predefined functions so hope you understood these simple concept this is this is string handling functions we have seen that first of all we have see the string length so string copies in concatenation string comparison string reverse and then over to opera number 2 number so for everything we have just used the predefined functions we did write any logic so these operations can be implemented without using the string handling functions so we can find the length of the string without using steel string length function so we should not use a single function we have to write the logic and compare string comparison so without using this string compare function strcmp function we how to compare two strings and we have to return the SK difference or we can have to return the output whether the strings are equal or strings are unequal and similarly for every operation without losing the string handling functions also we can implement the string operations so we can perform the copy string copy without using str CB we can perform string concatenation without losing its strcmp so we can convert the lowercase characters to uppercase character without fusing str UPR we can convert all the uppercase characters to lowercase characters without losing sta LWR so we are just making use of these predefined functions which are presented which are which are implemented in the header file that is string dot H so hope you understood these string handling functions or string operations these predefined functions so let us stop here and if you are having any doubts regarding these two strings concept or any other doubt regarding this is a language feel free to post your doubts in the compensation so definitely I will try to clarify your notes and if you like my videos share my videos with your friends and do subscribe to my channel for more videos on the technical concepts thanks for the listening thank you very much
Info
Channel: Sundeep Saradhi Kanthety
Views: 94,696
Rating: 4.8261948 out of 5
Keywords: sundeep, saradhi, kanthety, c language, c programming, cp, computer, computer programming, loops, strings, character arrays, string operations, string handling functions, string length, string copy, string compare, string concatenation, string reverse, conversion of lower to upper case, conversion of upper to lower case, strlen(), strcpy(), strcat(), strcmp(), strrev(), strlwr(), strupr()
Id: b-5beEPeV0c
Channel Id: undefined
Length: 35min 18sec (2118 seconds)
Published: Thu Oct 26 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.