I need to install a simulator in my ubuntu. It is written in C++ and when I try to run make, I get this error strlen was not declared in this scope
. Any solution to overcome this error?
You forgot to include <cstring> or <string. h> . cstring will give you strlen in the std namespace, while string. h will keep it in the global namespace.
You have the following options: Write using namespace std; after the include and enable all the std names: then you can write only string on your program. Write using std::string after the include to enable std::string : then you can write only string on your program. Use std::string instead of string.
C++ Programming The C++ String class has length() and size() function. These can be used to get the length of a string type object. To get the length of the traditional C like strings, we can use the strlen() function. That is present under the cstring header file.
This should do it :
#include <cstring>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With