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’ .
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- Check if a string is palindrome in C using pointers
- Program to Reverse a String using Pointers
- C++ Program to compare two string using pointers
- How to find length of a string without string.h and loop in C?
- Count of sub-strings of length n possible from the given string
- C program to find the length of a string
- Find longest length number in a string
- Counts of distinct consecutive sub-string of length two using C++ STL
- Pointers vs References in C++
- What are near, far and huge pointers?
- Features and Use of Pointers in C/C++
- Pointers in C/C++ with Examples
- Applications of Pointers in C/C++
- Output of C programs | Set 64 (Pointers)
- Chain of Pointers in C with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.