 Hello friends. I am Sanjay Gupta. I welcome you on Sanjay Gupta Tech School. In this video I am going to explain how you can copy a string into another. So we will be copying the content of one string into another as it is with the help of loop. So I am not going to use any predefined function. So we have one predefined function as skrcpy. So this is a predefined function which is available in skrcpy.h. So I am not going to use that predefined function. Instead I will be telling you how you can write your own logic so that you can copy one string into another. Before start I just want to share my information. If you go to detail or description of this video you will find links of videos, playlist related to C language so you can watch them too. So now first I am going to create one string. So let's say its name is s1. These are the indexes. And it is having these as values. India. And after this last A it is having null character which is end of this string. Then I have one more string. So this is blank. These are the indexes and total size of both the strings are 10. So I need to copy all the contents which are available in this first string into second to a loop. So now I am going to write a program so that you can understand how this will work. So first I am declaring two character arrays. So s1 size 10, s2 size 10. I am declaring one variable i that is of integer type. Then this printer will print the masses. Enter a string and getters will be reading the content into s1. So now I am going to iterate a loop on s1 which will copy the content into s2. So this is the loop i equals to 0. So s1 of i not equals to null character and i plus plus. And inside this loop I need to write s2 of i equals to s1 of i and I am closing this loop. So the contents which are available in s1 string will be copied into s2 string with this loop. So now I am going to iterate this. So initially i is 0. So let's say value of i is 0. Check this condition s1 of i. So i is 0. So s1 of 0 position is having this capital i. So capital i is not equals to null. So this condition is true. Both are unequal. So this s1 of i position value that is capital i will be stored into s2 of i position. So for this string i is also 0. So its 0 position will be having i as a value. Then i will be incremented. So this time it is having value as 1. So check s1 of 1. It is having capital and which is not equals to null. Again condition is true. So s1 position 1 index value and will be copied into s2 at i index. So i is 1. It will be having n at 1 index. Then d will be copied, i will be copied and a will be copied. So when i is 2, d will be copied. If i is 3, i will be copied. If i is 4, a will be copied. And if i, this loop counter value is 5. So here you can see at 5th position or 5th index. At 5th index you can see null is available. So null not equals to null. This condition is false because both are equal. So this loop is terminated. So now you can see s1 is having null at the end of all the characters. But s2 is not having null character at the end of all the characters. So it means right now s2 is not considered as string because it is not having null. So after completion of this loop, we need to put this. Why so? Because when we are reaching on null position for s1 string, then this loop is terminating. This condition is making false. So it is terminating. So a loop is not copying null character to this s2 string. So after completion of this loop, we need to do it manually. So we are copying null. So put null in single quotes because it is a character constant. And it will be copied into s2 of i position. So after termination of this loop, you can see value of i is 5. So s2 5th index, this will be having null copied with this manual step. So it will come after completion of this loop. Now you can print string 2 equals to percent s and s2. So with this print s, all the contents of s2 will be printed on output string. So remember that if your string is not having null character at the end, then it is not treated as string. It will be treated as a character array only. So you need to put a null character manually if your loop is not putting that automatically. So remember this thing and also this percent s will print the string till this null character. If it is not available, so it will print all the characters which are available in this planned positions. So those output will become garbage output. So don't forget to put null character explicitly if your automated process is not capable to put that. So I hope you understood how we can copy a string into another with the help of this loop. And I didn't use this sqrcpy because it is predefined function. So I explained you how you can implement a loop which will work similar to sqrcpy. So I hope you understood whatever I explained in this video. If you want to watch more programming related videos, you can go to my channel, go to playlist. Or you can go to description or detail of this video where you can find all the links related to C language playlist. So watch them and thank you for watching this video.