0

How can I check length of string in this code?

https://code.sololearn.com/cGyaOWRuRwRF/?ref=app

18th Sep 2019, 8:29 AM
Raj Tiwari
2 Answers
+ 2
You declared `char string[20];` It is a C-String, a char array, it is not a std::string. Your condition `if (string.size() >= 8)` doesn't work, because a char array doesn't have any method by the name 'size'.
18th Sep 2019, 8:45 AM
Ipang
+ 2
You can use the sting type instead of a char array. The string type has a length() method that returns the strings length.
18th Sep 2019, 8:46 AM
Aaron Eberhardt
Aaron Eberhardt - avatar