Saturday, 23 March 2013

C++ program tell you the size of String which You have entered



#include<iostream.h>
#include<conio.h>
#include<cstring.h>


void main()
{
    char arr[20];
    int a,count;

    count=0;

    cin.getline(arr,20,'\n');

    for(a=0;a<20;a++)
    {
        if(arr[a]!='\0')
        {
            count++;

        }
        else if(arr[a]=='\0')
        {
            break;
        }
    }

    cout<<"\n\nThe size is = "<<count;

    getch();
}