Use std::string::size
or std::string::length
(both are the same).
As you insist to use strlen
, you can:
int size = strlen( str.c_str() );
note the usage of std::string::c_str
, which returns const char*
.
BUT strlen
counts untill it hit \0
char and std::string
can store such chars. In other words, strlen
could sometimes lie for the size.