+ 1
why strlen isn't working here????please help me
https://code.sololearn.com/ca3a9a15445A ./Playground/file0.cpp: In function 'int main()': ./Playground/file0.cpp:13:16: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const char*' 13 | cout<<strlen(str)<<endl; | ^~~ | | | std::string {aka std::__cxx11::basic_string<char>} In file included from ../Playground/++/10.2.0/cstring:42, from ./Playground/file0.cpp:3: ../Playground/:384:35: note: initializing argument 1 of 'size_t strlen(const char*)' 384 | extern size_t strlen (const char *__s) | ~~~~~~~~~~~~^~~
3 odpowiedzi
+ 2
It's because *str* is of type std::string and strlen() works on C style strings ( char * or char[] )
Use str.length() to get desired results
https://code.sololearn.com/c1FwiNcRqTGs/?ref=app
0
Error what i am getting pasted in description...
Please look in to it and please help me
0
Arsenic thanks bro.....