To find the length of the string using pointers
Program:
#include<stdio.h>
#include<conio.h>
void main()
{
char *str;
int len = 0;
clrscr();
printf("Enter a string : ");
scanf("%s", str);
while(*str != '\0')
{
len++;
str++;
}
printf("\nThe length of the string is : %d", len);
getch();
}
Output:
Enter a string : bhuvan
The length of the string is : 6
-
UpdatedDec 31, 2019
-
Views14,814
You May Like
Program to maintain employee details using structures
Program to maintain student details using structures
Check whether the person is eligible to vote or not
Print the numbers that are divisible by a given no.
Program to generate magic square
To sort the given numbers in ascending & descending order