+ 2
How to cin string & how to get the string length ?
6 Respostas
+ 2
yes@immortal
+ 2
tnx @immortal
+ 2
It depends on what string type you're talking about. There are many types of strings for example:
1.....const char* you can use strlen() [ const char *str = "hello";
std::cout << str << ":" << strlen(str); ]
2....std::string you can use .size() or .length() methods. [ std::string str = "hello";
std::cout << str << ":" << str.length(); ]
....