Wednesday, 14 November 2012

C Program to find the length of the string using pointer

By
Using pointers, find the length of the given string.

Program : -

#include<stdio.h>
#include<conio.h>
void main()
{
char string[100];
char *p;
int length=0;
clrscr();
printf("|*******************|");
printf("\nwww.flintgroups.com\n");
printf("|*******************|\n");
printf("Enter a string : \n");
gets(string);
for(p=string;*p!='\0';p++);
length=p-string;
printf("\nLength of string is : %d",length);
getch();
}


The sample output for this program is as shown below.

1 comment:

  1. This comment has been removed by the author.

    ReplyDelete

Related Posts Plugin for WordPress, Blogger...

Labels