0

How can we return the Length of Strings in C++?

How can we do string.Length from C#, in C++?

11th Jun 2017, 6:40 AM
Ervin Samuel
Ervin Samuel - avatar
2 Respostas
+ 3
Or if your string is of type char*: char* str="Hello"; cout<<str<<":"<<strlen(str)<<endl; //Prints Hello:5
11th Jun 2017, 12:03 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 1
call length(): Example: std::string str = "Foo"; std::cout << str << ":" << str.length(); // Outputs "Foo:3"
11th Jun 2017, 6:46 AM
Tim