The length of a string using pointers
Write a program to find the length of a string using pointers .
Input : given_string = "geeksforgeeks" Output : length of the string = 13 Input : given_string = "coding" Output : length of the string = 6
Prerequisite : Pointer in C
Approach Used : In this program we make use of * operator. The * (asterisk) operator denotes the value of variable . The * operator at the time of declaration denotes that this is a pointer, otherwise it denotes the value of the memory location pointed by the pointer. In the below program, in string_length function we check if we reach the end of the string by checking for a null represented by ‘\0’ .