Search Me..Find Best!

Sunday, April 6, 2014

Learning c++-stringlength in C++ and String size in C++

//For amzing source codes,ebooks and projects keep visiting imagzi.blospot.com

//Program used to find the length of the String and size of the String 

//courtesy imagzi.blospot.com

#include<iostream>
#include<iomanip>
#include<cstring>
using namespace std;
int main()



{
int i,size;
char name[]={"My name is techlabb.blospot.com"};
//find length
cout<<"The string is : ";
for(i=0;i<=strlen(name);i++)
{
cout<<name[i];
}
cout<<endl;//the Cout ended so new line for new message
cout<<"The total alphabets used in the String is : "<<strlen(name)<<endl;
//find size
size=sizeof(name);
cout<<"The size of the string is "<<size;
return 0;
}


0 comments:

Post a Comment