C++ program to find the length of user entered string

A Simple C++ program to find the length of user entered string.In this program we have used the two properties of Strings 1. The terminating character or end of string marker ‘\0’ and the special property of character array in which character identifier represents the address of first element of the character array(i.e string).

#include <iostream.h>
#include <conio.h>
int strlength(char*);

int main()
char s1[20];
int length;
cout<<"Enter the String ";


cout<<"Length of String = "<<length<<endl;



int strlength(char *s1)

int i=0,len=0;

// if(s1[i]==' ') /* Uncomment these two lines to omit spaces between the strings in length calculation */
// continue;





Adarsh Vengarathodi

Adarsh Vengarathodi is a serial entrepreneur and the CEO and founder of MistLayer, Inc. MistLayer is an ICT Company headquartered in San Francisco offering a full range of technology products, solutions, and services. MistLayer delivers innovative products that augment the lives of thousands of people around the world.

You may also like...