 Hello welcome to the session on user function in C to concatenate two strings. At the end of this session, the student will be able to write a C program to concatenate two strings using their own function that is without using library function strcat. C string function it is having strcat for concatenate two strings that is strcat here which joins two given strings. Now we can see the prototype or syntax of this is character pointer strcat then we are having destination pointer and source pointer. It takes two arguments that is two strings or character array and stores the result concatenated string in the first string specified in the argument. So for example we can see here strcat str1, str2 here what will happen? It will join str1 and str2 in this way first str1 will be copied and then str2 will be joined to that str1 and whatever the resultant value is there it will be into the destination that is the first string str1. So when you will find when you will go to the str1 you will find two concatenated strings. So here we will see a simple program which is using library function strcat that is the concatenation of the two string. Now here we are including strio.h but also we are including string.h which will help to run the function strcat which is a library function and its support by string.h. So here we are having two strings a and b, a string is having a array of characters of 1000, b string is having array of character of 1000. Now here print will take first string enter the first string with the help of get as a. Then we will use enter the second string which will get second string that is b. Then we are using this library function strcat a comma b and then we will print string which is after joining a and b which is stored into the a that is the first string and then return 0. Here we will check the output we are asked for the first string here with the get as a it will give c second string it will give user will give programming. Now we will run strcat on a and b, a and b then we are getting output is a that is first a string then programming that is the second string and this output you will find into the string a that is the first string. Now we will try to write the function that is the user function without using strcat. So we will create a user function for string concatenation. We increment destination array string pointer till it is a null. Then we will go to the source string and it will be copied at the end of this first string of the target string. Then one more condition will be here that is the destination string array size should be enough sufficient to copy source string that is addition of string a and string b that should be accommodated into the string a that is the destination string. So while declaring any destination string you check that what is the size of both string and enough keep the enough space. We can see two strings are there source string and destination string. In the source string we are having a single character c and it is having the null character. Then in the destination string we are having program and null. So here we are having six characters and here single character. So after running strcat our source string will be having only the whatever the previous string as it is and at the destination first having program plus whatever the c. So that will be destination plus source. Now here we will see the user program how the user program is there. Here in this case main program we will declare the function that is a void concatenate character and second character array that is having string 1 and string 2. Now in this main we are declaring the string p and q. So here we are printing first input a string that is a p then input a string for the concatenation with the q that is a gate sq. After concatenate this will be the user function we need to write this so p,q so it will go here void concatenate character p and character q that is the array of p and q. Then inside that we will be declaring integers c and d which will help for the counting. So c is equal to for 0 then go for the string that is the destination string that is the first string p of c 1 by 1 as it is till it is a null and we are going to increment character by character character by character and we will complete this while loop. Then next our second string is there the counter for the second string is d is equal to 0 we initialize that counter then while q of d is not equal to null we are going to add that into the array of the first string we are here at the null character at that point the second string is started that is the string 2 so we are incrementing this array for the copying the second array so it is incremented d and incremented c up to the null once the second string is completed we will stop this all the loop now we will see how it happens first we are inputting string c input a string to concatenate is program now the c is first here that is str1 or here we are calling as a array of p and then we are going for the second that is the program first it will be copied c then null will be happened and then the second counter will start here because this loop will complete of the first string the second loop will be started d is equal to 0 that is the p first then it will be copied on r o g r a double m r n g and once this total character will be completed in the string second then this second array second loop will be completed so total you will be getting c programming at the one that is p so we are writing that obtained string on the concatenation is c programming now here pause the video and you try to write a function string concatenation using pointer for given this main program in the main program we have declared void concatenate underscore string this is the function two strings are their character original and add in enter the source string it will be getting the original string then enter the string to concatenate then that add string will be get and then you will call the function and you need to write this function and once it run you will be printing that original so try for this here it is a solution function string concatenation using pointer so here while original pointer is there it will be go on and instrumenting the original pointer till first string is complete and then you will go to the second pointer that is the add pointer and your original pointer will be incremented and your add pointer which is the first character will be joined to the first string so we are incrementing our source as well as destination arrays and the end is going on so until you are getting the null of add you are incrementing the both pointer and you are copying or joining the both strings so this is the solution for your string concatenation using pointer references thank you