C Program To Find Length Of A String Including Blank Spaces, Tabs, And Other Special Characters

How to write a C Program To Find Length Of A String Including Blank Spaces, Tabs, And Other Special Characters in C Programming Language ?


Solution For C Program :

/*C Program To Find Length Of A String Including Blank Spaces, Tabs, And Other Special Characters.*/

/*New line character will be taken as a string terminating character.*/
#include<stdio.h>
#include<conio.h>
#include<string.h>
int xstrlen(char *);
void main()
{
char s1[20];
int len;
clrscr();
printf("\nEnter the string:");
gets(s1);
len=xstrlen(s1);
printf("\nlength of the string =%d",len);
getch();
}
int xstrlen(char *s)
    {
    int l=0;
    while(*s)
      {
      l++;
      s++;
      }
    return (l);
    }


You may also learn these C Program/Code :

C Program To Swap Two Numbers Without Using Third Variable


Learn More :