Showing posts with label strlen. Show all posts
Showing posts with label strlen. Show all posts

20130504

How to find the length of a string without using library function strlen


/*How to find length of a string without using library function strstr.
How to use pointer/array to find length of string sentence. C++/CPP/C program/code to find length a string/word/sentence without using inbuilt function strlen.How to find the length of a string without using library function strlen*/
#include<stdio.h>
#include<string.h>

int strLen(char *p);

int main()
{
char arr1[20];
printf("Enter a String:\n");
scanf("%s",&arr1);

printf("You entered:%s\n",arr1);
int n;
n=strLen(arr1);
printf("Strlen of entered string is:%d\n",n);