I have declared a string array String s;
I tried finding the length of the string by giving strlen(s) but it didnt work . How to get the length of the string ?
I have declared a string array String s;
I tried finding the length of the string by giving strlen(s) but it didnt work . How to get the length of the string ?
The function strlen does not take a string, but an array of chars. Please see this reference for examples. If you are using the type string you will find it's length by using the function length(), like this:
std::string text = "Some text";
int length = text.length();
For more examples see this other question.
string s;
declares a string named s, not an array of strings, which would be
string array[10];
for instance. To get the length of a string, you call its size() or length() method:
size_t len = s.size();