 Hello, welcome to the session on user function in C to copy one string into another. Let's see the learning outcome. At the end of this session, the student will be able to write a C program to copy one string into another using their own function. There is one library function to copy string in C language is strcpy. In the strcpy prototype, the function is character strcpy character star destination and it is copying from the source. So the strcpy function copies the string pointed by source including the null character to the character array destination. This function returns character array destination. The strcpy function is defined in str string.h header file. For example, here strcpy in the bracket we are having str1 and str2. str1 is here destination and str2 is source. It copies the string 2 into the string 1. We will see in the program how we are using this strcpy built in function first and then we will move to the user function. Here first string copy built in function strcpy first program here directly I have shown that character s1 and character s2 has given 30 character array in the memory. So first character s1 of 30 will be stored here directly a string 1 and character s2 that is s2 variable will store string 2. Now we will use the library function. This function has copied now s2 into s1 when we are using strcpy s1 comma s2 and then we are printing that s1 that will be now copied value is string s1 is s2. Now one more program only here we are changed in the definition of the string. Here again character, source and destination they are capable of storing 100 of character and then print input string and we are getting the string with the help of get as source and then we are using strcpy that is the library function destination comma source. So source string will be copied into the destination then we are printing source as well as destination. Here output is shown input string I have given waltz now source string will be after the using strcpy source string will be waltz and destination string will be also waltz. So one more program here again the variable declaration is different. First we are used here str1 with 10 string that can have 10 character here we are directly given that string is awesome and second str2 string we are not defined here just we are given the variable for the storage. Now strcpy here we are using str2 comma str1 and second is strcpy is str3 comma well. So this well will be directly copied into the str3 and here str1 which is declared here as awesome that will be copied into the s2. So when we are putting put s str2 what will be given so whatever this copied from str1 is awesome that will be given awesome and put s str3 will be given directly whatever this well we have given the string well directly that will be copied into the str3 and when we are giving put s it will be giving str3 that is well. So up to this we have seen that we were using library function which is already built in in the c program. Now here we can see how user can write his own string copy function. So here logic will first see what is the logic we create user function to copy string for that we scan one by one the characters in the source string if the character is a null then copy character from source string to source string array to destination string array. Now destination string array size should be enough so that that can be copy the source string then once the null character is found we will stop copying this character by character from source to destination. So more elaboration here I have shown that user function to copy now first source string is here it is containing array of the string that is s1, s2, s3, s4, s5 and it is holding the string is WRT and then it is showing that null so it is a end of this string and destination string is having hello h, e, w, l, o and then null character. Now after execution of this what will happen see source string is as it is WIT with null and you can see the destination is having WIT instead of we were having hello character. Now we will write function for the string copy that is the user function you can see here include stdio.h here no need of the string.h in the main counter is initialize c and then we are having two string declared s1000 and d1000 and d1000 is already destination is having my program. Now we will print first before copying the string and then then we will go for the input a string which need to be copied by gait s now here we can see that while using while is up to the when we are not getting the null character the destination is going to be copy from the source and c is the counter that is the index from 0 then it will be going on increasing with the help of c++ and we are doing this up to when we are not having the null character and then last we will be having the null character at the end of this string once the source string is finished then we are printing the after copying whatever the string is there. So we will see the output output is before copying the string my program is there then input a string then we are having my output and then after copying into the string it will be my output so that will be source will be copied into the destination. The user function can be written with the help of function also. So here main program function so in the main program we are having declaration that include STD I would add then this declaration is about the function which we are going to use for the copy the string. Now here we can see that while copy string this is the array of the character first and array of the character second. In the main we are having the two strings S and D of size 100 and 100 then we are inputting a string get S and then we are calling once the source is there we are calling the function copy string D, S so whatever the source is here it will be copied into the D and then we are going to copy whatever the copied string that will be print. Now this is the function in the function we are having wide copy string here we are initializing the counter C is equal to 0 that is the index for the array then while it is not null we are going to copy that destination from the source incrementing the counter and then we are completing this copy and then we are copying that last character with null character. So this is the output input string welcome and then copied string we have printed is welcome. Now pause video for a second and write a function to copy a string into another using pointer here is the solution with the help of pointer also we can use we can write a function to copy string here pointers we are using target pointer and source pointer then we are checking the source pointer whenever the content of the source pointer it is showing it will be copying to the target and once it is finding the null it will be completed the copy of the string and once finishing that string we are copying the null character at the end of the string references. Thank you.