-->

Facebook

Jasper Roberts - Blog

Tuesday, April 28, 2015

Write a program using pointer and function to determine the length of string.

#include<stdio.h>

#include<conio.h>
#include<stdio.h>
#include<conio.h>
void ptr();

void main()
{
clrscr();
ptr();
getch();
}
void ptr()
{

    char s[100];
    char *p;
    int length;

    printf("\n Enter the string:");
    scanf("%s",s);

    for(p=s;*p!='\0';p++);

    length=p-s;

    printf("Length of the string is::%d",length);
     }

No comments:

Post a Comment