Let us see the C++ Program to find the length of the string using the separate Nested Structures.
C++ Code of Separate Nested Structures C++ Program to find the length of string
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
//Nested strucutre #include<iostream> #include<string.h> using namespace std; struct lengthstring { char str[10]; }; struct length { char a; lengthstring s; }; int main() { length l; int len; cout<<"please enter your desired string"<<endl; cin>> l.s.str; len=strlen(l.s.str); cout<<"The length of your desired string is:"<<len<<endl; return 0; } |
Output
please enter your desired string
t4tutorials
The length of your desired string is: 11