 Hello friends, I am Sanjay Gupta. In this video, I am going to demonstrate you how you can copy a string into another by passing string into function using pointer. Before starting, you can note my information, you can follow or subscribe my YouTube channel through the URL youtube.com slash sanjaygupta underscore tech school. You can download my programming app tech image which is available on Google Play. Now I am going to implement a solution of this problem in front of you. So first I am including a header file that is STDI dot H. Now I am going to declare a function whose name is copy. Its return type is void and its argument type is character pointer and I will be passing two addresses of character arrays. That's why two times character pointer is declared here. So this statement is function declaration. Now I am going to define main function. Inside main, I am declaring two character arrays S1 and S2. Then with the help of printer, the message enter string will be displayed on console and through gattus the entered content will be received and all contents will be stored inside S1. Now I am going to call copy function in which I am passing S1 and S2. So this statement is function calling. Now after completion of this call, the contents of S1 will be copied into S2. Now I can print the content of S2 on console through this printf and then return 0. So I am passing S1 and S2 in copy function. So their base addresses will be passed in its definition. So in definition S2 will be modified but its effect will be applied on this S2 array which is available in main function because call by address method will be applicable automatically. So now I am going to show how it will be done. So here you can see I am declaring two pointers which will receive base addresses of S1 and S2 and this block will be known as function definition. So here S1 array base address will be stored inside P1 and S2 array base address will be stored inside P2. So through P1 I can access elements of S1 array and through P2 I can point to the locations of S2. So if I am modifying values in P2 so it is indirectly modifying values of S2. So now I am implementing a while loop where condition is S risk P1 not equals to 0. So if this condition is true then only loop will be repeated otherwise it will be terminated. So now I am writing the statement S risk P2 equals to S risk P1. So P1's value so P1 is holding an address its value will be stored inside P2 then I have to increase P1 and then I have to increase P2. So this way P1 and P2 will be pointing to the next addresses which are available in the strings and then next element of that address will be stored inside P2 through P1. So this way all the contents of S1 string will be copied into S2 through P1 and P2 pointers. Now after completion of this loop null will not be copied. So I have to copy it explicitly through this statement. So S risk P2 equals to null so null will be copied into S2 string this way. So here I have implemented the complete implementation. So contents of S1 will be copied into S2 and I have passed both the strings into function and in function definition they are managed with the help of pointers. Now I am executing this code. I am entering Sanjay. You can see the output copied contains equals to Sanjay. So I have entered Sanjay into S1 but S2 is printing Sanjay also. So this means S1 contents are copied into S2 with the help of copy function and copy function is having pointers inside it. So this way I have passed string into function using pointer for copying a string into another. I hope you have understood this logic well. If you want to watch more programming related videos you can follow or subscribe my YouTube channel through the URL youtube.com slash sanjaygupta underscore tech school. You can download my programming app TechMS which is available on Google Play. Thank you for watching this video.