 Hello friends, I am Sanjay Gupta. In this video, I am going to demonstrate you how you can count length of string 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 Techimage which is available on Google Play. Now I am going to implement a program with the help of C so that I can demonstrate you how you can perform this operation which is available in front of you. So first I am including a header file that is STDF dot H. Now I am declaring a function whose name is length. Its written type is integer and it will receive address of the string or you can say base address of the string. So I have mentioned character pointer as an arguments type in this function declaration statement. So this is function declaration. Now I am going to define main function. Inside main, I am declaring a character array and a variable integer type length that is L. Now with the help of printf statement, I am going to display the message enter string on console to receive contents of string. I am using getters function and the content will be stored inside str. Now I am going to call length function and inside length function, I am passing string str. So this statement is function calling statement. So the outcome of this function calling will be stored inside L variable. Now I can print the value of L on console as length of string. So this way length of string will be displayed on console and then return 0. Now I have to define definition of length function. So this block will be known as function definition. Inside this function definition, I have to count how many characters are available in the string. But I have to do this task with the help of this pointer P. So here I am applying a for loop sorry while loop where condition is asterisk P not equals to null. So you can see here asterisk P is a pointer which is having base address of str. So P is containing base address. If I am writing asterisk P, it means I am dereferencing that address. So first element of string will be checked whether it is equals to null or not. So if it is not equals to null, then this loop will be true. So here I can increase value of L by 1. It means one character is available in this string. Then for moving to next location of the string, I am incrementing P by 1. So P++ will be moving to the pointer on second location of the string. So this way this loop will repeat. If this condition is true, then this loop will be repeating. If this condition asterisk P not equals to null is false, then loop will be terminated. So after completion of this loop, I can return value of L so that it can be received at function calling statement. And then the result can be displayed on console. So this way I have implemented the complete solution in front of you that how you can count length of string by passing string into function using pointer. Now I am executing this code. I am entering Sanjay. So you can see the output. It is showing length equals to 6. So the program has counted number of characters which are available in the string entered by the user. I hope you have understood the concept well. If you want to watch more programming related videos, you can follow or subscribe my YouTube channel through the URL youtube.com. You can download my programming app Techimage which is available on Google Play. Thank you for watching this video.