Is there/What is the C++ version of the strlen function?

Hello there, I was working on my game engine's string class when I ran into an error while trying to compile on Linux (I normally compile with MSVC). The compiler tells me to include the 'cstring' header, which leads me to believe this is a deprecated C function. I would like to know what options I have in terms of real C++ functions, so please let me know :)
If you are dealing with C strings (char arrays) there is std::strlen() in the <cstring> header.
https://en.cppreference.com/w/cpp/string/byte/strlen

No, it isn't a deprecated C function, you just need to include a different header for C++ vs. C.

If you are dealing with C++ strings there is the size() or length() member function.
https://en.cppreference.com/w/cpp/string/basic_string/size
some decades ago, c++ stuffed all the standard stuff into namespaces and changed the headers to drop the .h for the new versions. its true in c++ too, eg <iostream> used to be <iostream.h>
most of the ones of the cword or cpartialword format are from C, though <cmath> is confusing and <chrono> just happens to start with c.
Last edited on
Topic archived. No new replies allowed.