Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

strlen was not declared in this scope - C++

Tags:

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?

like image 753
Vivek Avatar asked Dec 30 '10 17:12

Vivek


People also ask

Why strlen is not declared in this scope?

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.

How do I fix the string was not declared in this scope?

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.

Can we use strlen in C++?

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.


1 Answers

This should do it :

#include <cstring> 
like image 93
icecrime Avatar answered Oct 26 '22 20:10

icecrime