Strlen Program

#include <iostream.h>
 #include <string.h>
 int main()
 {
 char *string1 = "abcdefghijklmnopqrstuvwxyz";
 char *string2 = "four";
 char *string3 = "Boston";
 cout << "The length of \"" << string1
 << "\" is " << strlen( string1 )
 << "\nThe length of \"" << string2
 << "\" is " << strlen( string2 )
 << "\nThe length of \"" << string3
 << "\" is " << strlen( string3 ) << endl;
 return 0;
 }
 OUTPUT:
        The length of "abcdefghijklmnopqrstuvwxyz" is 26
        The length of "four" is 4
        The length of "Boston" is 6

No comments:

Post a Comment