42.string length



1. Using function

#include <stdio.h>
#include <string.h>

int main()
{
   char a[100];
   int length;

   printf("Enter a string to calculate it's length\n");
   gets(a);

   length = strlen(a);

   printf("Length of entered string is = %d\n",length);

   return 0;
}


2.Without function

#include <stdio.h>

int main()
{
   char array[100], *pointer;
   int length = 0;

   printf("Enter a string\n");
   gets(array);

   pointer = array;

   while(*(pointer+length))
      length++;

   printf("Length of entered string = %d\n",length);

   return 0;
}

:)
:(
hihi
:-)
:D
=D
:-d
;(
;-(
@-)
:P
:o
:>)
(o)
:p
:-?
(p)
:-s
(m)
8-)
:-t
:-b
b-(
:-#
=p~
$-)
(y)
(f)
x-)
(k)
(h)
cheer